wood burning stoves
The moose likes Other JSE/JEE APIs and the fly likes SMTP issue using javamail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "SMTP issue using javamail" Watch "SMTP issue using javamail" New topic

SMTP issue using javamail

Derek Boylan

Joined: May 15, 2012
Posts: 1

I am having an issue using SMTP/javamail that has only sometimes occurs. I have been running the code that uses SMTP without issue for months until recently when i have been getting the following error message:

14.05.2012 11:35:49 [DefaultQuartzScheduler_Worker-10] ERROR Task execution failed.
com.util.email.api.EmailNotificationException: javax.mail.MessagingException: Could not connect to SMTP host: relay.testserver.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused
at com.util.email.api.BaseNotification.send(BaseNotification.java:394)
at com.util.email.api.BaseNotification.send(BaseNotification.java:370)
at com.util.email.EmailNotificationServiceImpl.send(EmailNotificationServiceImpl.java:72)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: relay.testserver.com, port: 25;
nested exception is:
java.net.ConnectException: Connection refused
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:140)
at com.util.email.api.BaseNotification.send(BaseNotification.java:392)
... 8 more
Caused by: java.net.ConnectException: Connection refused
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:367)
at java.net.Socket.connect(Socket.java:524)
at java.net.Socket.connect(Socket.java:474)
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)
... 15 more

Nothing has changed in the code that would have had any impact on the functionality of SMTP. When i use netstat the port appears to be open and listening and i am able to us telnet to ping the mail server.

I am running:
- javamail-1.4.3
- jdk1.5.0_22
- Linux Redhat 5.5

Here is some snippets of code that i have been using (successfully):

at com.util.email.EmailNotificationServiceImpl.send(EmailNotificationServiceImpl.java:72)

at com.util.email.api.BaseNotification.send(BaseNotification.java:394)
at com.util.email.api.BaseNotification.send(BaseNotification.java:370)

I agree. Here's the link: http://aspose.com/file-tools
subject: SMTP issue using javamail
jQuery in Action, 3rd edition