【问题标题】:Authentication failure when using mail Grails plugin使用邮件 Grails 插件时身份验证失败
【发布时间】:2017-01-24 15:44:20
【问题描述】:

我正在使用 Grails 2.5.1ma​​il:1.0.7 插件发送电子邮件,但是当我使用它时,我总是收到以下错误:

Class:javax.mail.AuthenticationFailedExceptionMessage:535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/answer/14257 qq4sm4579366wjc.14 - gsmtp

虽然我可以使用提供的凭据从浏览器成功登录!!

这是我在 Config 文件中的配置:

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

这是行动:

 mailService.sendMail{
        to userInstance.toEmail
        subject  userInstance.subject
        html "<strong>Test</strong> "
    } 

我缺少什么?

【问题讨论】:

    标签: grails grails-plugin


    【解决方案1】:

    这可能是因为 gmail 的安全功能可以让不太安全的应用通过身份验证。只需为不太安全的应用打开访问权限即可。

    按照以下步骤操作:

    1 登录您的 gmail 帐户

    2 访问网址: https://www.google.com/settings/security/lesssecureapps

    3 选择“开启”

    【讨论】:

      【解决方案2】:

      如果你有 gmail - 插件的设置是正确的(我有相同的并且它们正在工作),但是如果你的电子邮件不是 gmail,你必须有其他配置

      顺便说一句,如果你 gmail :

      Username and Password not accepted.
      

      您的用户名或密码错误,请尝试使用此用户名和密码登录,注意收信。 https://grails.org/plugin/mail

      【讨论】:

      • 我通过浏览器登录检查了所有凭据,它正在工作,但在我的代码中工作并给我同样的错误,提到的配置有什么问题吗?
      猜你喜欢
      • 2013-11-13
      • 2013-12-16
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 2018-11-02
      • 2014-07-28
      • 2012-09-21
      • 2011-10-20
      相关资源
      最近更新 更多