org.apache.commons.mail.EmailException: Sending the email to the following server failed : anyhost.com:25

Apache's JIRA Issue Tracker | Kevin Lester | 7 years ago
  1. 0

    An incorrect error message is being returned from the email class when a message fails to send due to a blocked port and SSL is specified. Specificaly, the port number in the error message is incorrect; it will show the stmp port that is set on the object (normally 25), when it should be showing the port that was set in the session when the session was created [465 when SSL is used]. This issue is only visible to the user if the email fails to send because the SSL port is blocked. The following code reproduces the issue: public void testErrorMessage(){ HtmlEmail email = new HtmlEmail(); try { email.addTo("abc@d.com"); email.setSubject("Testing Apache Error message "); email.setFrom("abc@d.com"); email.setMsg("Sending through gmail"); email.setSSL(true); email.setHostName("anyhost.com"); email.send(); } catch (EmailException e) { e.printStackTrace(); } } If port 465 is blocked, then you wil ge the following stacktrace: org.apache.commons.mail.EmailException: Sending the email to the following server failed : anyhost.com:25 at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1138) at org.apache.commons.mail.Email.send(Email.java:1163) at EmailTester.testErrorMessage(EmailTester.java:27) at EmailTester.main(EmailTester.java:14) Caused by: javax.mail.MessagingException: Could not connect to SMTP host: anyhost.com, port: 465; nested exception is: java.net.ConnectException: Connection refused: connect 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) ... Note that the port is listed correctly in the inner exception, but it is incorrect in the topmost exception. I have fixed this issue in my sandbox, and will attach the patch to this issue.

    Apache's JIRA Issue Tracker | 7 years ago | Kevin Lester
    org.apache.commons.mail.EmailException: Sending the email to the following server failed : anyhost.com:25
  2. 0

    ひさびさ - mokkouyou2001の日記

    ne.jp | 1 year ago
    org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:587
  3. 0

    Usando org.apache.commons.mail e deu erro 25 ????

    com.br | 1 year ago
    org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    email plug in cant send out email - Forums - Joget Workflow Community Site

    joget.org | 1 year ago
    org.apache.commons.mail.EmailException: Sending the email to the following serve r failed : mail.dsop.com.my:25
  6. 0

    Cannot change transport_email_port by configuration

    Google Groups | 3 years ago | Ray Chang
    org.apache.commons.mail.EmailException: Sending the email to the following server failed : mailxxx.xxx.com:465

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.apache.commons.mail.EmailException

      Sending the email to the following server failed : anyhost.com:25

      at org.apache.commons.mail.Email.sendMimeMessage()
    2. Apache Commons Email
      Email.send
      1. org.apache.commons.mail.Email.sendMimeMessage(Email.java:1138)
      2. org.apache.commons.mail.Email.send(Email.java:1163)
      2 frames
    3. Unknown
      EmailTester.main
      1. EmailTester.testErrorMessage(EmailTester.java:27)
      2. EmailTester.main(EmailTester.java:14)
      2 frames