使用邮件Grails插件时身份验证失败

时间:2015-10-09 22:57:42

标签: grails grails-plugin

我正在使用 Grails 2.5.1 mail: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

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

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

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> "
    } 

我错过了什么?

2 个答案:

答案 0 :(得分:0)

这可能是因为gmail的安全功能可以让不太安全的应用程序获得身份验证。只需为不太安全的应用启用访问权限。

按照以下步骤操作:

1登录您的Gmail帐户

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

3选择&#34;打开&#34;

答案 1 :(得分:-1)

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

顺便说一句,如果你gmail:

Username and Password not accepted.

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

相关问题