commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30946] New: - [email] - being able to specify the port number
Date Mon, 30 Aug 2004 21:26:39 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30946>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30946

[email] - being able to specify the port number

           Summary: [email] - being able to specify the port number
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Sandbox
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: phil-apache@whirlycott.com


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());

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message