【问题标题】:Sending mails with grails application error发送带有 grails 应用程序错误的邮件
【发布时间】:2011-12-12 12:29:00
【问题描述】:

我正在尝试使用邮件插件从我的 Grails 应用程序发送邮件。它适用于开发环境和 gmail smtp 的默认设置。我现在已经在运行 Tomcat 7 并尝试通过 Exchange 发送邮件的 Windows 服务器上部署了应用程序。我收到此错误:

这些是 config.groovy 中的邮件属性:

grails {
mail {
  host = "mail.something.com"
  port = 25
  username = "app@something.com"
  password = "xxx"
  props = ["mail.smtp.auth":"true",
           "mail.smtp.socketFactory.port":"25",
           "mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
           "mail.smtp.socketFactory.fallback":"false"]
}

}

javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client

at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:590)

at javax.mail.Service.connect(Service.java:291)

at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:102)

at grails.plugin.mail.MailMessageBuilder$sendMessage.call(Unknown Source)

at grails.plugin.mail.MailService.sendMail(MailService.groovy:39)

at grails.plugin.mail.MailService$sendMail.call(Unknown Source)

at org.helpdesk.RequestController$_closure12.doCall(RequestController.groovy:240)

at org.helpdesk.RequestController$_closure12.doCall(RequestController.groovy)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

我该怎么办?谢谢。

【问题讨论】:

    标签: tomcat grails sendmail


    【解决方案1】:

    清楚地说明出了什么问题:

    javax.mail.AuthenticationFailedException: No authentication mechansims supported by both server and client
    

    您的 Gmail SMTP 设置不适用于 Exchange 服务器。您需要更改设置。只是搜索它。这是一个涉及 Java Mail 和 Exchange 服务器的问题:JavaMail Exchange Authentication,您可能对 Java Mail FAQ 中的这个主题感兴趣:http://www.oracle.com/technetwork/java/faq-135477.html#Exchange-login

    【讨论】:

    • 正如我所说,我正在使用 grails 邮件插件。不是 Java 邮件。所以你的例子对我没有帮助。如果你可以请更具体。
    • @drago - 邮件插件使用 JavaMail;您在Config.groovy 中指定的配置本质上是JavaMail 的配置。这个答案应该对你有帮助。
    • 感谢@Rob 的澄清。 drago - 你应该更多地自己阅读文档和搜索 Google 和 StackOverflow,而不是要求即时和完整的答案。您的评论清楚地表明,甚至没有检查我提供的链接。
    • @TomaszKalkosiński 我确实检查了你的链接,但我觉得我需要探索 grails 邮件插件,然后是 spring 和 java 邮件,所以感觉有点矫枉过正。这个link 结合你的链接帮助我理解了我需要做什么。
    【解决方案2】:

    这些设置适用于 Gmail(只需更改用户名/密码):

    grails.mail.from = "First Last <some_name@gmail.com>"
    grails.mail.host = "smtp.gmail.com"
    grails.mail.port = "465"
    grails.mail.username = "some_name@gmail.com"
    grails.mail.password = "xxx-password-xxx"
    grails.mail.props = ["mail.smtp.auth": "true",
            "mail.smtp.socketFactory.port": "465",
            "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",
            "mail.smtp.socketFactory.fallback": "false",
            "mail.smtp.starttls.enable": "true",
            "mail.debug": "true"]
    

    【讨论】:

    • OP 想要通过 Exchange 而不是 Gmail 发送邮件,并提到他们的 Gmail 设置已经正常工作。
    猜你喜欢
    • 1970-01-01
    • 2016-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多