英文:
Not able to send email via smtp.gmail.com on AWS EC2
问题
我无法通过在aws es2
上使用smtp.gmail.com
和route53
发送电子邮件,但在我的本地系统上运行良好。
我正在使用以下配置:
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=xxxxxx@gmail.com
spring.mail.password=######
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=false
收到的错误
org.springframework.mail.MailAuthenticationException: 身份验证失败;嵌套异常是 javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu
534-5.7.14 ee9D-Q4FF1Qf1C0brZ5yyBgjly-Dcd72KznHCmCiWukMqfhBZYF0hoXQaIYmvy-POsSpm
534-5.7.14 dz-R07OXf5mfyVmnCtydKpyoNNWYQOUTE7ZE4ecOjqrFL9cMf0rG6WhCjRP3IObV>
534-5.7.14 请通过网络浏览器登录,然后重试。
534-5.7.14 了解更多信息,请访问以下网址
534 5.7.14 https://support.google.com/mail/answer/78754 j9sm2100533pfe.170 - gsmtp
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:440)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:361)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:356)
at org.ravi.aveefashion.service.EmailService.sendMail(EmailService.java:42)
at org.ravi.aveefashion.demo.RestServices.sendEmail(RestServices.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
我的gmail中的lesssecure
设置已开启,并且IMAP访问也已启用。
英文:
I am not able to send an email via app using smtp.gmail.com
on aws es2
with route53, however It is working fine on my local system
I am using following configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=xxxxxx@gmail.com
spring.mail.password=######
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=false
Error Received
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu
534-5.7.14 ee9D-Q4FF1Qf1C0brZ5yyBgjly-Dcd72KznHCmCiWukMqfhBZYF0hoXQaIYmvy-POsSpm
534-5.7.14 dz-R07OXf5mfyVmnCtydKpyoNNWYQOUTE7ZE4ecOjqrFL9cMf0rG6WhCjRP3IObV>
534-5.7.14 Please log in via your web browser and then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 j9sm2100533pfe.170 - gsmtp
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:440)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:361)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:356)
at org.ravi.aveefashion.service.EmailService.sendMail(EmailService.java:42)
at org.ravi.aveefashion.demo.RestServices.sendEmail(RestServices.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
My lesssecure
setting in gmail is on and IMAP assess is also enabled.
答案1
得分: 2
看起来代码没有问题,AWS 配置也没有问题。是 Gmail 阻止了登录尝试。所以我需要做两件事情,
**1. 在设置中启用“允许不安全的应用程序访问”
2. 转到 `https://accounts.google.com/DisplayUnlockCaptcha` 并点击继续**
英文:
It seems there is no problem in the code and there is no problem in AWS configuration. It was gmail which was blocking login attempt. So I have to do two things,
**1. turn on Allow less secure apps in settings
2. go to `https://accounts.google.com/DisplayUnlockCaptcha and click continue**
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论