【问题标题】:issue with Grails mail plug in , Connection refused: connectGrails 邮件插件问题,连接被拒绝:连接
【发布时间】:2014-04-15 14:41:53
【问题描述】:

我安装了邮件插件:

grails install-plugin mail

我根据插件添加了我的配置:

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

我在我的 Bootstrap.groovy 中添加了一个 sendMail

class BootStrap {
    def mailService

    def init = { servletContext ->

        try{
            mailService.sendMail {
             from "username@gmail.com"
             to "username@gmail.com"
             subject "Hello"
             body "Mail"
            }
           }catch (Exception e){
            println e
           }
    }
    def destroy = {
    }
}

但是当我执行应用程序时,我得到了

java.net.ConnectException: Connection refused: connect

完整的错误日志是

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout -1;
  nested exception is:
    java.net.ConnectException: Connection refused: connect. Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout -1;
  nested exception is:
    java.net.ConnectException: Connection refused: connect; message exceptions (1) are:
Failed message 1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 465; timeout -1;
  nested exception is:
    java.net.ConnectException: Connection refused: connect

【问题讨论】:

  • 我留下了一个应该作为评论留下的答案。道歉。其内容是指出 install-plugin 命令已被弃用一段时间了。您应该改为编辑 BuildConfig.groovy 并在那里表达依赖关系。
  • 就我而言,我使用的是旧密码

标签: grails grails-2.0 grails-plugin


【解决方案1】:

重新启动服务器,它会为您工作。当我这样做时,它对我有用。

希望对你有帮助!!

【讨论】:

    【解决方案2】:

    我刚刚将一个示例项目推送到github.com/jeffbrown/maildemo,其中包含您发布的配置,并且它可以正常工作。请参阅Config.groovyBootStrap.groovy

    您是否使用了可能导致问题的代理?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-21
      • 2014-04-09
      • 1970-01-01
      • 2016-08-06
      • 1970-01-01
      • 2012-01-03
      • 2013-09-23
      相关资源
      最近更新 更多