【问题标题】:Email not sent via Gmail - Username and Password not accepted电子邮件未通过 Gmail 发送 - 不接受用户名和密码
【发布时间】:2014-11-15 18:15:33
【问题描述】:

我在尝试通过 Gmail 发送电子邮件时收到此错误。这是 config.groovy 文件中的代码。

mail.MailMessageBuilder Failed to send email
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 ca4sm3178528pbd.79 - gsmtp

        at grails.plugin.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy:112)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 ca4sm3178528pbd.79 - gsmtp

        at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:843)
        at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:765)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:687)
        at javax.mail.Service.connect(Service.java:345)
        ... 4 more

代码:

grails {
    mail {
      host = "smtp.gmail.com"
      port = 465
      username = "yomama@gmail.com"
      password = "TTYUIoiuy78"
      props = ["mail.smtp.auth":"true",
               "mail.smtp.socketFactory.port":"465",
               "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
               "mail.smtp.socketFactory.fallback":"false"]
    }
 }

我尝试了提供的链接中建议的解决方案。

我已登录并更改了密码。 我解锁了验证码 DisplayUnlockCaptcha 我也点了allow less secure apps access the app

【问题讨论】:

标签: grails gmail grails-plugin


【解决方案1】:

我遵循了这些步骤,我没有收到任何错误并且工作正常..

  1. 使用命令为 grails 安装邮件插件

    grails install-plugin mail 1.0.7
    
  2. 打开 Config.groovy 并附加这些行

     grails {
             mail {
                  host = "smtp.gmail.com"
                  port = 465
                  username = "your gmail id"
                  password = "your password"
                  props = ["mail.smtp.auth":"true",
                  "mail.smtp.socketFactory.port":"465",
                  "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
                  "mail.smtp.socketFactory.fallback":"false"]
                  }
           }
    
  3. 在您要发送邮件的操作中使用此代码

    sendMail {
           to "recepient address"
           subject "Hello Fred"
           body 'How are you?'
           }
    
  4. 使用编译您的应用程序

    grails compile
    
  5. 运行应用

【讨论】:

  • 我的也可以在本地运行,但不能在远程服务器上运行。
猜你喜欢
  • 2015-11-13
  • 2018-03-03
  • 1970-01-01
  • 2020-11-08
  • 2015-06-29
  • 2015-06-10
  • 2020-01-06
  • 2011-02-19
  • 2020-01-19
相关资源
最近更新 更多