Java Mail連線時, 需確認IPV6是否為關閉, 否則會無法連線.
javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.SocketException: Network is unreachable: connect
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.pic.framework.util.RainbowMailTest.main(RainbowMailTest.java:72)
若是使用Eclipase啟Tomcat時,
於VM arguments最後加入-Djava.net.preferIPv4Stack=true
若為單機程式, 則需設定properties
properties.setProperty("java.net.preferIPv4Stack", "true");
沒有留言:
張貼留言