我想在Grails的配置ZOHO邮件服务邮件的插件 。 下面是我的配置到目前为止,
grails {
mail {
host = "smtp.zoho.com"
port = 465
username = "email@valid.com"
password = "some-valid-password"
props = ["mail.smtp.auth":"true",
"mail.smtp.starttls.enable":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
这是我的服务方法。 上述配置的伟大工程,如果我把Gmail的SMTP配置,所以我觉得这是与服务方法一点问题都没有。 此外email@valid.com是Zoho的一个注册的电子邮件,我可以使用ZOHO的仪表板发送电子邮件。
def sendImageProcessedNotification(User user, imageLink){ try{ if(user){ def receiver = user.email mailService.sendMail { async true to receiver subject "Subject" html "Html body" } } }catch(e){ log.error(e) } }
这里是堆栈跟踪,
2015-07-19 08:17:37,782 [pool-12-thread-1] ERROR mail.MailMessageBuilder - Failed to send email org.springframework.mail.MailSendException: Failed to close server connection after message failures; nested exception is javax.mail.MessagingException: Can't send command to SMTP host; nested exception is: java.net.SocketException: Connection closed by remote host. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as ; message exception details (1) are: Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 553 Relaying disallowed as at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2133) at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:1912) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1135) at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:433) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340) at org.springframework.mail.javamail.JavaMailSender$send$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:110) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:122) at grails.plugin.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy:112) at grails.plugin.mail.MailMessageBuilder$_sendMessage_closure1.doCall(MailMessageBuilder.groovy) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207) at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1121) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016) at groovy.lang.Closure.call(Closure.java:423) at groovy.lang.Closure.call(Closure.java:417) at groovy.lang.Closure.run(Closure.java:504) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)