2012-03-29 126 views
1

我可以編譯我的代碼但不執行。可能是什麼原因,我應該如何排序
我得到以下運行時錯誤。 SMTP客戶端程序給出運行時錯誤

C:\>java SMTPClient 
Exception in thread "main" javax.mail.MessagingException: Could not connect to S 
MTP host: smtp.mail.yahoo.com, port: 465; 
nested exception is..................etc</b></code> 

回答

1

The reason is that it cannot connect to the Yahoo Mail Server. I'm unsure of Yahoo's mail port so ensure that the port is correct. Can you post more details? I.e. the nested exception....

+0

C:\> java SMTPClient 線程「main」中的異常javax.mail.MessagingException:無法連接到 MTP主機:smtp.mail.yahoo.com,端口:465; 嵌套的例外是: javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorEx 主器件接收:PKIX路徑建設失敗:sun.security.provider.certpath.SunCertPathBu lderException:無法找到有效的認證路徑請求的目標 – 2012-03-29 15:07:49

+1

看起來像你需要一個SSL證書 – 2012-03-29 15:09:11

2

Please provide the root causeStack trace的例外。 這可能是因爲你還沒有配置Authenticator

+0

我不能夠發佈整個錯誤,因爲每次我得到OOPS你的代碼不能粘貼,因爲它有代碼我試圖添加代碼標籤,但它沒有幫助 – 2012-03-29 15:08:49

+1

試試這個:http:///www.java-samples.com/showtutorial.php?tutorialid=210 – Shams 2012-03-29 15:18:45

2

可能SMTPClient使用SMTP協議,但雅虎使用更安全的ASMTP。你可以在這裏發佈你的SMTPClient類嗎?