使用javaMail时出现SocketException

时间:2017-02-27 11:03:36

标签: linux debugging smtp javamail socketexception

我在Linux中使用JavaMail时遇到SocketException。

调试模式中的错误消息如下所示。

16:12:57,123 INFO  [STDOUT] DEBUG: setDebug: JavaMail version 1.4.2
16:12:57,128 INFO  [STDOUT] DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
16:12:57,130 INFO  [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
16:12:57,130 INFO  [STDOUT] DEBUG SMTP: useEhlo true, useAuth true
16:12:57,130 INFO  [STDOUT] DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 25, isSSL false
16:12:57,415 INFO  [STDOUT] 220 smtp.gmail.com ESMTP z4sm29890425pge.49 - gsmtp
16:12:57,416 INFO  [STDOUT] DEBUG SMTP: connected to host "smtp.gmail.com", port: 25
16:12:57,416 INFO  [STDOUT]
16:12:57,416 INFO  [STDOUT] EHLO testserver
16:12:57,639 INFO  [STDOUT] 250-smtp.gmail.com at your service, [125.16.129.234]
16:12:57,639 INFO  [STDOUT] 250-SIZE 35882577
16:12:57,640 INFO  [STDOUT] 250-8BITMIME
16:12:57,640 INFO  [STDOUT] 250-STARTTLS
16:12:57,640 INFO  [STDOUT] 250-ENHANCEDSTATUSCODES
16:12:57,640 INFO  [STDOUT] 250-PIPELINING
16:12:57,641 INFO  [STDOUT] 250-CHUNKING
16:12:57,641 INFO  [STDOUT] 250 SMTPUTF8
16:12:57,641 INFO  [STDOUT] DEBUG SMTP: Found extension "SIZE", arg "35882577"
16:12:57,642 INFO  [STDOUT] DEBUG SMTP: Found extension "8BITMIME", arg ""
16:12:57,642 INFO  [STDOUT] DEBUG SMTP: Found extension "STARTTLS", arg ""
16:12:57,642 INFO  [STDOUT] DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
16:12:57,642 INFO  [STDOUT] DEBUG SMTP: Found extension "PIPELINING", arg ""
16:12:57,643 INFO  [STDOUT] DEBUG SMTP: Found extension "CHUNKING", arg ""
16:12:57,643 INFO  [STDOUT] DEBUG SMTP: Found extension "SMTPUTF8", arg ""
16:12:57,643 INFO  [STDOUT] STARTTLS
16:12:57,644 INFO  [STDOUT] DEBUG SMTP: exception reading response: java.net.SocketException: Connection reset
16:12:57,645 ERROR [STDERR] javax.mail.MessagingException: Exception reading response;
16:12:57,645 ERROR [STDERR]   nested exception is:
16:12:57,645 ERROR [STDERR]     java.net.SocketException: Connection reset
16:12:57,647 ERROR [STDERR]     at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764)
16:12:57,647 ERROR [STDERR]     at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1632)
16:12:57,647 ERROR [STDERR]     at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1483)
16:12:57,648 ERROR [STDERR]     at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:462)
16:12:57,648 ERROR [STDERR]     at javax.mail.Service.connect(Service.java:313)
16:12:57,648 ERROR [STDERR]     at javax.mail.Service.connect(Service.java:172)
16:12:57,649 ERROR [STDERR]     at javax.mail.Service.connect(Service.java:121)
16:12:57,649 ERROR [STDERR]     at javax.mail.Transport.send0(Transport.java:190)
16:12:57,649 ERROR [STDERR]     at javax.mail.Transport.send(Transport.java:120)

请帮助我理解为什么发生此套接字异常(连接重置)?

编辑:

解答:

我解决了这个问题。这是新的防火墙阻止。 防火墙已启用smtp端口,但不知何故还不够。

请关闭此票。

0 个答案:

没有答案