繁体   English   中英

Grails 3邮件:必须先发出STARTTLS命令

[英]Grails 3 mail: Must issue a STARTTLS command first

我知道这个问题已经在许多不同的地方被问过很多次了,但是由于某种原因,我似乎无法使其正常工作。 我意识到问题出在哪里,我似乎无法弄清楚yaml语法或类似的简单内容。

我正在使用带有“邮件”插件(2.0.0.RC6)的Grails 3。

这是我的application.yml的片段:

grails:
    serverURL: <url>
    mail:
        host: <host>
        port: 587
        username: <username>
        password: <password>
        props:
            ? "mail.smtp.auth" : true
            ? "mail.smtp.starttls.enable" : true
            ? "mail.smtp.starttls.required" : true
            ? "mail.smtp.socketFactory.class" : "javax.net.ssl.SSLSocketFactory"
            ? "mail.smtp.socketFactory.fallback" : false
            ? "mail.smtp.port" : 587

我尝试过很多没有成功的引号组合。 ? 而不是-表示地图,这就是我想要的。

如果有帮助,这是特定的错误消息:

Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first

        at grails.plugins.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:130)
        at grails.plugins.mail.MailService.sendMail(MailService.groovy:53)
        at grails.plugins.mail.MailService.sendMail(MailService.groovy:57)
        at website.UserController.register(UserController.groovy:60)
        ... 3 common frames omitted

这是运行Postfix(首次设置)的自定义邮件服务器。 我能够连接到它并使用Thunderbird发送邮件。 Thunderbird正在使用STARTTLS和端口587进行连接。 据我所知,我无法仅执行SSL / TLS。

更新:

我已经删除了出厂配置,并修复了Yaml地图内容。 现在我又遇到了一个错误。

grails:
    serverURL: https://test.neonorb.com
    mail:
        host: test.neonorb.com
        port: 587
        username: neonorb
        password: pass
        props:
            mail.smtp.starttls.enable: true
            mail.smtp.port: 587

这是例外:

unable to find valid certification path to requested target. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. Failed messages: javax.mail.MessagingException: Could not convert socket to TLS;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at grails.plugins.mail.MailMessageBuilder.sendMessage(MailMessageBuilder.groovy:130)
        at grails.plugins.mail.MailService.sendMail(MailService.groovy:53)
        at grails.plugins.mail.MailService.sendMail(MailService.groovy:57)
        at website.UserController.register(UserController.groovy:60)
        ... 3 common frames omitted
Caused by: javax.mail.MessagingException: Could not convert socket to TLS
        at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2046)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:711)
        at javax.mail.Service.connect(Service.java:366)
        ... 7 common frames omitted
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:598)
        at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:525)
        at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2041)
        ... 9 common frames omitted
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        ... 12 common frames omitted
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
        ... 12 common frames omitted

根据Google的说法,这是因为证书是自签名的,而Java不信任它。 我的证书不是自签名的,而是由Let's Encrypt制作的。

摆脱套接字工厂属性 ,它们早已过时。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM