troubleshooting Question

JavaMail stopped working... with Software caused connection abort: connect

Avatar of bganoush
bganoush asked on
JavaJava EE
10 Comments1 Solution1039 ViewsLast Modified:

Hello World!

I have been using JavaMail in my application for a while and until last month it has been working great.  Now all I get is a MessageException every time my app tries to send()...

Here is the main emailing code:

private void sendReport()
{
      try
      {  
            Properties props = System.getProperties();
            props.put("mail.smtp.host", m_SMTPServer);

            Session session = Session.getDefaultInstance(props, null);
            session.setDebug(true);

            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(m_From));
            msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(m_To, false));
            msg.setSubject(m_Subject);
            msg.setHeader("X-Mailer", "MyApplicationName");
            msg.setSentDate(new Date());

            //msg.setText(getBody());
            //msg.setText("Test Message");
            msg.setContent("Test Message", "text/plain");

            Transport.send(msg);
      }
      catch (Exception e)
      {
            ErrorLog eLog = new ErrorLog(m_Config);
            eLog.log("Report Error: Caught exception trying to send email: " + e.getMessage());
      }
}


Here is the exact error message and a stack dump:

      Report Error: Caught exception trying to send email: Could not connect to SMTP host: my-relay-server-was-here, port: 25;
 nested exception is:
            java.net.SocketException: Software caused connection abort: connect

Stack Dump:

javax.mail.MessagingException: Could not connect to SMTP host: my-relay-server-was-here, port: 25;
  nested exception is:
      java.net.SocketException: Software caused connection abort: connect
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1227)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:322)
      at javax.mail.Service.connect(Service.java:236)
      at javax.mail.Service.connect(Service.java:137)
      at javax.mail.Service.connect(Service.java:86)
      at javax.mail.Transport.send0(Transport.java:150)
      at javax.mail.Transport.send(Transport.java:80)
      at myApp.sendReport(MyThread.java:125)
      at myApp.run(MyThread.java:190)


When I turn debugging on "session.setDebug(true)", I get this:

DEBUG: setDebug: JavaMail version 1.3.3
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "my-relay-server-was-here", port 25, isSSL false



Anyone have any idea what could be going wrong and how to fix it?

-- Bubba

ASKER CERTIFIED SOLUTION
Giant2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros