我的邮件发送程序已经使用几年了,都没有问题,最近突然发生了问题。
javax.mail.SendFailedException。
但是我们的用户还是收到邮件了,不知道为什么既然有了发送失败的异常,为什么还能收到邮件呢,而且一直抛出这个异常。以前从来没有过。 Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", smtphost);
props.put("mail.store.protocol", "pop3");
props.put("mail.pop.host", pop3host);
session = Session.getDefaultInstance(props, null);从来都是这么用的,没有问题。
希望大家帮忙解决,谢谢了,很紧急。
javax.mail.SendFailedException。
但是我们的用户还是收到邮件了,不知道为什么既然有了发送失败的异常,为什么还能收到邮件呢,而且一直抛出这个异常。以前从来没有过。 Properties props = new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", smtphost);
props.put("mail.store.protocol", "pop3");
props.put("mail.pop.host", pop3host);
session = Session.getDefaultInstance(props, null);从来都是这么用的,没有问题。
希望大家帮忙解决,谢谢了,很紧急。
session = Session.getDefaultInstance(props, null);
改为
session = Session.getInstance(props, null);
试试看?从代码来看,你的SMTP服务器不需要验证?你自己的SMTP服务器吗?还是别人的允许匿名发送的SMTP服务器?提个建议,把SendFailedException的详细信息贴出来吧,绝对有助于问题的解决。呵呵。
这个是部分log[9/30/08 16:21:58:682 SGT] 0000002b SystemErr R java.lang.Exception: SendFailed Exception. javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused: connect
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at xxx.utils.mail.Mailer.SendMessage(Mailer.java:114)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at xxx.servlet.feedback.FeedbackBean.sendFeedback(FeedbackBean.java:76)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at xxx.servlet.feedback.FeedbackServlet.DoProcess(FeedbackServlet.java:80)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at n1engine.com.servlet.n1_HttpServlet.service(n1_HttpServlet.java:100)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.servlet.SingleThreadModelServlet.service(SingleThreadModelServlet.java:127)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:972)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:907)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at ema.filter.ErrorDetectionFilter.trackRequestedURL(ErrorDetectionFilter.java:58)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at ema.filter.ErrorDetectionFilter.doFilter(ErrorDetectionFilter.java:45)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:696)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:641)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1425)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:92)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:193)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:725)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:847)
[9/30/08 16:21:58:713 SGT] 0000002b SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1498)我很奇怪的是既然有这个异常,为什么用户还可以收到邮件呢?我换成我的邮件地址,就没有收到过
也许这些异常是其它程序所致,与你的程序无关?
这一切,必须看实际情况才能得出结论,网友是很难帮得上忙了。自己再好好检查一下吧。