Home > OS >  Sending mails not working when deployed application to aws
Sending mails not working when deployed application to aws

Time:09-17

When I run my application locally, everything works correct, mails are sent, but I deployed my application to aws EC2 and I get this:

org.springframework.mail.MailAuthenticationException: Authentication failed;

I have less secure apps turned off on my gmail account I send emails from, the two steps verification is also turned off. As I said, everything was working before I deployed the app to aws.

Properties:

mail:
     host: smtp.gmail.com
     username: <my.mail>@gmail.com
     password: <my.password>
     port: 587
     protocol: smtp
     properties:
       mail.smtps.auth: true
       mail.smtp.starttls.enable: true
       mail.smtp.ssl.trust: smtp.gmail.com

Am I missing any property or something like this?

CodePudding user response:

This looks like duplicate from:

javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1

CodePudding user response:

Ok, I finally solved this. The problem is that google blocks EC2 ports so what I needed to do was to turn on 2 steps verification in my google account -> then create new password (option under setting 2 steps verification) -> set this password in my .yml file as the new one -> everything works

I also set the SMTP rules in my EC2 security groups but I am not sure if it had any impact or the steps I have descripted above are enough

  • Related