(grails)com.sun.mail.smtp.SMTPSendFailedException:553转发不允许作为zoho邮件

时间:2015-07-19 12:52:13

标签: grails smtp grails-plugin zoho

我正在尝试在grails mail-plugin中配置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)

2 个答案:

答案 0 :(得分:4)

您只需要提及添加电子邮件逻辑的“setFrom()”属性。 示例:我使用了JavaMailSender并使用MimeMessage发送电子邮件,因此在这种情况下,我将不得不提到“helper.setFrom()”。

P.S:我已经尝试了很多方法,之后我用这个解决了它。

答案 1 :(得分:1)

删除此行"mail.smtp.starttls.enable":"true",添加此行"mail.smtp.startssl.enable":true