【发布时间】: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