Javax邮件异常 [英] Javax Mail Exception

查看:113
本文介绍了Javax邮件异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我不知道问题出在哪里,但是我正在将Netbeans 6.9.1与tomcat 6.0.2一起使用,并且有一个邮件库试图发送电子邮件,但是在方法上给了我一个错误:Transport.send( message );
sendEmail(sSMTP, sFrom, sEmail, sSubject, sMessage);
并在网页上显示:
Could not connect to SMTP host: <hostname>, port: 25</hostname>
能否请您提供任何建议.
它在Netbeans/tomcat上给我一个例外:

Hello
I don''t know where the problem is but I am using netbeans 6.9.1 with tomcat 6.0.2 and have a mail lib trying to send an email but gives me an error on the method: Transport.send( message );
sendEmail(sSMTP, sFrom, sEmail, sSubject, sMessage);
and on the webpage it gives me:
Could not connect to SMTP host: <hostname>, port: 25</hostname>
Can you please give any advices.
It gives me an exception on Netbeans/ tomcat:

javax.mail.MessagingException: Could not connect to SMTP host: <hostname>, port: 25;
  nested exception is:
        java.net.ConnectException: Connection refused: connect
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
        at javax.mail.Service.connect(Service.java:288)
        at javax.mail.Service.connect(Service.java:169)
        at javax.mail.Service.connect(Service.java:118)
        at javax.mail.Transport.send0(Transport.java:188)
        at javax.mail.Transport.send(Transport.java:118)
        at tracking.DBQuery.sendEmail(DBQuery.java:1821)
        at tracking.DBQuery.resetPassword(DBQuery.java:1354)
        at org.apache.jsp.resetpassword_jsp._jspService(resetpassword_jsp.java:80)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Caused by: java.net.ConnectException: Connection refused: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
        at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
        ... 30 more</hostname>

推荐答案

您在这里

修复链接-解决方案

发送失败的;嵌套的异常是:javax.mail.MessagingException:无法连接到SMTP主机:localhost,端口:25;嵌套的异常是:java.net.ConnectException:连接被拒绝:connect [问题排查-#100005-邮件发送 [ JavaMail API –通过Gmail SMTP示例发送电子邮件 [ ^ ]
Here you go

Fix links - solutions

Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25; nested exception is: java.net.ConnectException: Connection refused: connect[^]
Troubleshooting - #100005 - Mail Sending[^]

Free attachment
JavaMail API – Sending email via Gmail SMTP example[^]


连接被拒绝.

请检查您的电子邮件服务器.它们有时具有禁止"功能.它会执行应做的事情-禁止您进行一定数量的错误登录尝试.

这可能真的很烦人,特别是在开发过程中.

还要检查禁令期间是否设置了规则",有些规则会将禁令作为服务器的简单限时规则来处理.
The connection is refused.

Please check your email-server. They sometimes have a ''ban'' function. It does what it''s supposed to do - it bans you with a certain number of false login attempts.

This can be really annoying, specially while development.

Also check if there are "rules" set up during ban, some handle the ban as a simple limited time rule for the server.


这篇关于Javax邮件异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆