Question

Gmail smtp not able to send email javax.mail.AuthenticationFailedException:

I have set gmail for less secure app already Also set IMAP forwarding

Locally sending emails works but the problem occurs in

digital ocean droplet [without ssl or domain] via ip address

Email Setting using java simple mail

private EmailMailer(){
        setMailer(new Mailer(new ServerConfig("smtp.gmail.com", 587,EmailConstants.EMAIL_ID, EmailConstants.EMAIL_PASSWORD),
                TransportStrategy.SMTP_TLS));
    }

Checked Digital ocean was able to connect to port 587

Getting error while sending mail


Caused by: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuD
ww-app_1    | 534-5.7.14 ywow3CZ7TbpX5mHNs0LChqgXAsXoucspMfedy2oAIDqjP0MH4RO8M_1bLvhh6f3Ha0Fj_a
ww-app_1    | 534-5.7.14 RhfPx0WlDHIfsXUR8rbVLiSrSAr-hfc0PsOweMs0xMqQhHb6LhXMusyjtsfGzF> Please
ww-app_1    | 534-5.7.14 log in via your web browser and then try again.
ww-app_1    | 534-5.7.14  Learn more at
ww-app_1    | 534 5.7.14  https://support.google.com/mail/answer/78754 a6sm8956026qth.74 - gsmtp
ww-app_1    | 
ww-app_1    |   at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:914)
ww-app_1    |   at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:825)
ww-app_1    |   at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:730)
ww-app_1    |   at javax.mail.Service.connect(Service.java:388)
ww-app_1    |   at javax.mail.Service.connect(Service.java:246)
ww-app_1    |   at javax.mail.Service.connect(Service.java:195)
ww-app_1    |   at org.simplejavamail.mailer.internal.mailsender.MailSender.sendMailClosure(MailSender.java:252)
ww-app_1    |   ... 59 more
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @cbondy

Can you confirm if you have 2 factor authentication enabled as well? I had a similar case and I’ve needed to turn less secure app ON test my code and and then turn it off again.

Have you tried doing so?

Regards, Alex