简体   繁体   中英

Spring java mail : send mail impossible with yahoo

I am trying to user spring java mail with theses properties:

mail:
        host: smtp.mail.yahoo.com
        port: 587
        username: xxx
        password: xxx
        protocol: smtp
        properties.mail.smtp:
            auth: true
            starttls.enable: true

Code:

@Inject
private JavaMailSenderImpl javaMailSender;
...

MimeMessage mimeMessage = javaMailSender.createMimeMessage();
message.setTo(to);
message.setFrom(fromEmail);
message.setSubject(subject);
message.setText(content, isHtml);
javaMailSender.send(mimeMessage);

But I am getting this error when I send the mail:

E-mail could not be sent to user 'xxx@yahoo.fr', exception is: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 5.7.0 (#MBR1212) Incorrect username or password.

I am sure my login/pwd are correct. Are my properties incorrect?

Check your username / password, are you parsing it with plain text,string variable or char array, does it contains special character that needed to be escaped?

Make sure there is no empty space, extra space/break.

Your code and config are too narrow ,we can't help much to be honest. Are you able to send email using gmail account or other email? If you do so, there are problems in either yahoo config,such as port or the username password are indeed really incorrect.

Yes I am also using Yahoo mail and connecting with Java mail, you need to set up a third party access key, and then you will be able to connect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM