Uploaded image for project: 'Commons Email'
  1. Commons Email
  2. EMAIL-44

[email] - being able to specify the port number

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 30946

    Description

      I needed to be able to do this:

      SimpleEmail email = new SimpleEmail();
      email.setHostName("mail.myserver.com");
      email.setPortNumber(2500);

      Here's the patch.

      phil.

      Index: Email.java
      ===================================================================
      RCS file:
      /home/cvspublic/jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/Email.java,v
      retrieving revision 1.16
      diff -u -r1.16 Email.java
      — Email.java 27 Aug 2004 11:43:14 -0000 1.16
      +++ Email.java 30 Aug 2004 20:32:59 -0000
      @@ -59,6 +59,7 @@
      public static final String CONTENT_TYPE = "content.type";

      public static final String MAIL_HOST = "mail.host";
      + public static final String MAIL_PORT = "mail.smtp.port";
      public static final String MAIL_SMTP_FROM = "mail.smtp.from";
      public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";
      public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
      @@ -111,6 +112,11 @@

      • to get property from system.properties. If still null, quit
        */
        private String hostName = null;
        +
        + /**
        + * The port number of the mail server to connect to. Defaults to the
        standard port (25).
        + */
        + private String portNumber = "25";

      /** List of "to" email adresses */
      private ArrayList toList = null;
      @@ -242,6 +248,16 @@

      { this.hostName = aHostName; }

      +
      +
      + /**
      + * Set the port number of the outgoing mail server.
      + * @param aPortNumber
      + */
      + public void setPortNumber(int aPortNumber)
      +

      { + this.portNumber = new Integer(aPortNumber).toString(); + }

      /**

      • Initialise a mailsession object
        @@ -264,7 +280,8 @@
        throw new MessagingException(
        "Cannot find valid hostname for mail session");
        }
        -
        +
        + properties.setProperty(MAIL_PORT, portNumber);
        properties.setProperty(MAIL_HOST, hostName);
        properties.setProperty(MAIL_DEBUG,new Boolean(this.debug).toString());

      Attachments

        Activity

          People

            Unassigned Unassigned
            phil-apache@whirlycott.com Philip Jacob
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: