日期:2014-05-20  浏览次数:20853 次

哪位大神能帮我看看因为这个错误发不出邮件应该怎么办呢?
org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.bnu.edu.cn:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at gui1127.MainPanel.send(MainPanel.java:613)
at gui1127.MainPanel.startActionPerformed(MainPanel.java:466)
at gui1127.MainPanel.access$100(MainPanel.java:26)
at gui1127.MainPanel$2.actionPerformed(MainPanel.java:340)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6290)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6055)
at java.awt.Container.processEvent(Container.java:2039)
at java.awt.Component.dispatchEventImpl(Component.java:4653)
at java.awt.Container.dispatchEventImpl(Container.java:2097)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4575)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4236)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4166)
at java.awt.Container.dispatchEventImpl(Container.java:2083)
at java.awt.Window.dispatchEventImpl(Window.java:2489)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:607)
at java.awt.EventQueue$1.run(EventQueue.java:605)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:621)
at java.awt.EventQueue$2.run(EventQueue.java:619)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: mail.bnu.edu.cn, port: 25, response: 554
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1922)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
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 org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
... 41 more
java mail

------解决方案--------------------
你没有设置端口吧
------解决方案--------------------

org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.bnu.edu.cn:25

这个错误明显是说你的程序发送邮件到 mail.bnu.edu.cn 的 25 端口,发生了错误。这还没到你的邮件代码呢。去检查一下你的机器是否可以访问mail.bnu.edu.cn这个域名,你的机器到mail.bnu.edu.cn的25端口是否畅通。最简单的方法:telnet一下

C:\Windows\System32>telnet mail.bnu.edu.cn 25

经过测试,我这里是可以telnet成功的。
------解决方案--------------------
aused by: javax.mail.MessagingException: Could not connect to SMTP host: mail.bnu.edu.cn, port: 25, response: 554