1

I used SimpleEmail from org.apache.commons.mail.SimpleEmail successful in Wildfly 8. Now, I migrated to Wildfy 9 and SimpleEmail does every time raise a connection exception.

The exception is thrown on email.send() in the code below:

try
{
    Email email = new SimpleEmail();
    email.setHostName("mail.gmx.net");
    email.setAuthenticator(new DefaultAuthenticator("sender@gmx.ch", "password"));
    email.setSSLOnConnect(true);
    email.setFrom("sender@gmx.ch");
    email.setCharset(org.apache.commons.mail.EmailConstants.UTF_8);
    email.setSubject("TestMail");
    email.setMsg("This is a test mail ... :-)");
    email.addTo("receiver@gmx.ch");
    email.send();

}

Exception trace:

org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.gmx.net:465
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
    at org.apache.commons.mail.Email.send(Email.java:1448)
    ...

Caused by: javax.mail.MessagingException: Could not connect to SMTP host: mail.gmx.net, port: 465, response: -1
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2042)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
    at javax.mail.Service.connect(Service.java:386)
    at javax.mail.Service.connect(Service.java:245)
    at javax.mail.Service.connect(Service.java:194)
    at javax.mail.Transport.send0(Transport.java:253)
    at javax.mail.Transport.send(Transport.java:124)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
    ... 53 more

Does anybody know where I need to search for the problem?

Sevan
  • 669
  • 1
  • 5
  • 18
badera
  • 1,495
  • 2
  • 24
  • 49
  • This error just indicates that server it cannot connect to your mail server mail.gmx.net. There is no further cause to why this is so. – Tomaz Cerar Jan 07 '16 at 12:03
  • I also thought that. But it really works on Wildfly 8 and on Wildfly 9 it does not - I tested it in parallel from the same PC. The mailserver was available. May it be an SSL problem? Is there probably a missing certficate? And the connection error is just an SSL handshake error and not a tcp connection error? – badera Jan 07 '16 at 14:50

0 Answers0