邮件服务器问题总结

          邮件服务器问题总结
一、 无配置TLS
1.1异常信息:Could not convert socket to TLS
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; message exception details (1) are:
Failed message 1:
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 com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1907)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:666)
        at javax.mail.Service.connect(Service.java:295)
        at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:397)
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:346)
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:341)
        at consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:104)
        at consumer.service.consumer.EmailsMessageService.consumerEmail(EmailsMessageService.java:56)
        at consumer.kafka.KafkaProxy.proxyService(KafkaProxy.java:31)
        at consumer.kafka.EmailSmsConsumer$1.run(EmailSmsConsumer.java:76)
        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)
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 sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:273)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1472)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:213)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:913)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:849)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1035)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1344)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
        at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:549)
        at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:486)
        at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1902)
        ... 12 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
        at sun.security.validator.Validator.validate(Validator.java:260)
        at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1454)
        ... 22 more
1.2解决方法:”mail.smtp.starttls.enable”, true
二、550
2.1异常信息: 550 5.4.1 1. Recipient Address Rejected - Access Denied
2.2出现这个问题可能是以下两个原因:1. 收信者端拒绝收信 2. 因特网安全系统的入侵防止机制阻挡了邮件寄信端IP地址或是寄信端邮件服务器IP地址被列入黑名单中。
三、TLS=false
3.1 异常信息:Client was not authenticated to send anonymous mail during MAIL FROM
org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
3.2 解决方法:"mail.smtp.starttls.enable", true
四、邮件超时
4.1异常信息:没明显的报错,但是线程阻塞了,没返回成功原因不明。
2016-12-27 11:38:05,485-[consumer.kafka.EmailSmsConsumer$1.run(EmailSmsConsumer.java:73)]-[DEBUG] 消费 partition7,当前线程名字:pool-10-thread-14,消费消息[B@6753f6a9
2016-12-27 11:38:05,486-[consumer.kafka.KafkaProxy.proxyService(KafkaProxy.java:28)]-[DEBUG] 进入proxyService方法,topic:Email_Topic
2016-12-27 11:38:05,486-[consumer.service.consumer.EmailsMessageService.consumerEmail(EmailsMessageService.java:56)]-[INFO] 消费端收到内容:EmailMessage
2016-12-27 11:38:05,489-[consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:100)]-[INFO] 发送邮件服务器:smtp.office365.com,邮箱密码:a1977f109676fd7f21eaf9db75c7f885,邮件发送者:abc@123.com
2016-12-27 11:38:05,489-[consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:107)]-[INFO] 邮件发给abc@123.com,邮件接收[Ljava.lang.String;@4f5bce23,
2016-12-27 11:41:53,740-[consumer.kafka.EmailSmsConsumer$1.run(EmailSmsConsumer.java:73)]-[DEBUG] 消费 partition0,当前线程名字:pool-10-thread-13,消费消息[B@108de152
2016-12-27 11:41:53,741-[consumer.kafka.KafkaProxy.proxyService(KafkaProxy.java:28)]-[DEBUG] 进入proxyService方法,topic:Email_Topic,data:EmailMessage
2016-12-27 11:41:53,741-[consumer.service.consumer.EmailsMessageService.consumerEmail(EmailsMessageService.java:56)]-[INFO] 消费端收到内容:EmailMessage 
2016-12-27 11:41:53,743-[consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:100)]-[INFO] 发送邮件服务器:smtp.office365.com,邮箱密码:a1977f109676fd7f21eaf9db75c7f885,邮件发送者:abc@163.com
2016-12-27 11:41:53,744-[consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:107)]-[INFO] 邮件发给abc@123.com, 2016-12-27 11:41:58,341-[consumer.service.consumer.EmailsMessageService.sendMailMethod(EmailsMessageService.java:110)]-[INFO] 邮件发送成功
4.2解决方法:"mail.smtp.connectiontimeout", 80000
"mail.smtp.timeout", 80000


五、javamail API和配置文档https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html

你可能感兴趣的:(邮件服务器问题总结)