1

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?

user1260928
  • 3,269
  • 9
  • 59
  • 105
  • 1
    Maybe this could help: [http://stackoverflow.com/questions/2016190/how-to-configure-spring-javamailsenderimpl-for-gmail](http://stackoverflow.com/questions/2016190/how-to-configure-spring-javamailsenderimpl-for-gmail)? – Frank Apr 27 '16 at 08:20
  • It seems my properties are correct but still invalid user/pwd – user1260928 Apr 27 '16 at 08:34
  • Could you add a little bit more code and the complete configuration? With the shown snippets it's like reading from a crystal ball. ;-) – Frank Apr 27 '16 at 08:38

3 Answers3

0

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.

PSo
  • 958
  • 9
  • 25
0

This is most likely Yahoo's new sign in method restrictions. Try this: https://help.yahoo.com/kb/mail-for-desktop/turn-account-key-sln25781.html or this: https://login.yahoo.com/account/security#less-secure-apps

K1w1Geek
  • 605
  • 5
  • 5
0

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.

WPW
  • 121
  • 7