Commons Email
  1. Commons Email
  2. EMAIL-26

[email] Bad Exception message when using a supplied MailSession


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Labels:
    • Environment:

      Operating System: Windows XP
      Platform: PC


      I create a MultiPartEmail object and supply a javax.mail.Session as a param to
      the setMailSession() method. I do not explicitly set the hostname or port.
      After stting the rest of the desired/required fields, I call send().

      I happened to have a javax.mail.MessagingException get thrown which was caught
      in Email, specifically, sendMimeMessage(). What I noticed was that the
      stacktrace in my log read the following:

      org.apache.commons.mail.EmailException: Sending the email to the following
      server failed : null:25
      at org.apache.commons.mail.Email.sendMimeMessage(
      at org.apache.commons.mail.Email.send(
      at org.quartz.simpl.SimpleThreadPool$
      Caused by: javax.mail.MessagingException: Could not connect to SMTP host:
      smtp.server.address, port: 25;
      nested exception is: Connection refused: connect
      at com.sun.mail.smtp.SMTPTransport.openServer(
      at com.sun.mail.smtp.SMTPTransport.protocolConnect
      at javax.mail.Service.connect(
      at javax.mail.Service.connect(
      at javax.mail.Service.connect(
      at com.sun.mail.smtp.SMTPTransport.connect(
      at javax.mail.Transport.send0(
      at javax.mail.Transport.send(
      at org.apache.commons.mail.Email.sendMimeMessage(
      ... 5 more

      As can be seen, the MessagingException knows the hostname (hostname changed to
      protect the innocent , yet the EmailException does not. After taking a
      closer look, the str that is generated for the Exception message uses the
      hostname property, yet upon tracing the code, the hostname never gets set by
      this code execution path.

      My expectation was that since I supplied a valid Session object (with
      hostname) that the Email class would be able to extract that info back out of


        Charles Deal created issue -
        dion gillard added a comment -

        Fixed with patch to 38656. Please let us know if this is still an issue.

        dion gillard added a comment - Fixed with patch to 38656. Please let us know if this is still an issue.
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 38538 12342888
        Henri Yandell made changes -
        Affects Version/s 1.0 Final [ 12311651 ]
        Project Commons [ 12310458 ] Commons Email [ 12310474 ]
        Component/s Email [ 12311114 ]
        Assignee Jakarta Commons Developers Mailing List [ ]
        Key COM-2736 EMAIL-26
        Henri Yandell made changes -
        Affects Version/s 1.0 Final [ 12311731 ]
        Siegfried Goeschl made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Charles Deal
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: