commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject cvs commit: jakarta-commons-sandbox/email/src/java/org/apache/commons/mail Email.java
Date Tue, 31 Aug 2004 12:00:55 GMT
matzew      2004/08/31 05:00:55

  Modified:    email/src/java/org/apache/commons/mail Email.java
  Log:
  subbmitted patch for bug-entrie #30946
  for supporting change of SMTP-Port.
  
  Revision  Changes    Path
  1.17      +22 -2     jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/Email.java
  
  Index: Email.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/email/src/java/org/apache/commons/mail/Email.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Email.java	27 Aug 2004 11:43:14 -0000	1.16
  +++ Email.java	31 Aug 2004 12:00:55 -0000	1.17
  @@ -45,6 +45,7 @@
    * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
    * @author <a href="mailto:unknown">Regis Koenig</a>
    * @author <a href="mailto:colin.chalmers@maxware.nl">Colin Chalmers</a>
  + * @author <a href="mailto:matthias@wessendorf.net">Matthias Wessendorf</a>
    * @version $Id$
    */
   public abstract class Email
  @@ -59,6 +60,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 +113,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 smtpPort = "25";
   
       /** List of "to" email adresses */
       private ArrayList toList = null;
  @@ -242,6 +249,18 @@
       {
           this.hostName = aHostName;
       }
  +    
  +    
  +    /**
  +     * Set the port number of the outgoing mail server.
  +     * @param 	aPortNumber
  +     */
  +    public void setSmtpPort(int aPortNumber) 
  +    {
  +    	if (aPortNumber < 1) 
  +    		throw new IllegalArgumentException("Cannot connect to a port number that is less
than 1 (" + aPortNumber + ")");
  +    	this.smtpPort= new Integer(aPortNumber).toString();
  +    }
   
       /**
        * Initialise a mailsession object
  @@ -264,7 +283,8 @@
               throw new MessagingException(
                   "Cannot find valid hostname for mail session");
           }
  -
  +        
  +        properties.setProperty(MAIL_PORT, smtpPort);
           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