我使用了不安全的电子邮件服务器(不是ssl)。
我发现421用于:421 - 服务不可用,连接将关闭。
Grails电子邮件插件配置:
grails {
mail {
host = "xxx.xxx"
port = 25
username = "username"
password = "secret"
props = ["mail.smtp.auth": "true",
"mail.smtp.socketFactory.port": "25"
]
}}
我得到的例外是:
Error Exception in thread "Thread-34"
| Error org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx, port: 25, response: 421. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx, port: 25, response: 421; message exception details (1) are:
| Error Failed message 1:
| Error javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx, port: 25, response: 421
| Error at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1694)
| Error at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:525)
| Error at javax.mail.Service.connect(Service.java:291)
| Error at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:389)
| Error at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)
| Error at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:336)
| Error at org.springframework.mail.javamail.JavaMailSender$send$0.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
| Error at grails.plugin.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:104)
| Error at grails.plugin.mail.MailMessageBuilder$sendMessage$0.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
| Error at grails.plugin.mail.MailService.sendMail(MailService.groovy:41)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:606)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
| Error at groovy.lang.MetaMethod$doMethodInvoke.call(Unknown Source)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at groovy.lang.MetaMethod$doMethodInvoke.call(Unknown Source)
| Error at GrailsMelodyGrailsPlugin$_closure4_closure16_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
| Error at sun.reflect.GeneratedMethodAccessor488.invoke(Unknown Source)
| Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
| Error at java.lang.reflect.Method.invoke(Method.java:606)
| Error at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
| Error at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
| Error at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1108)
| Error at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
| Error at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39)
| Error at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
| Error at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
答案 0 :(得分:2)
这适用于我当前主持人的制作。您可以向您的托管服务提供商咨询您的配置。
grails {
mail {
host = "localhost"
port = 25
props = ["mail.smtp.from":"no-reply@mydomain.com"]
}
}