epugh 2004/10/24 10:41:21 Modified: email/src/java/org/apache/commons/mail Email.java email/xdocs changes.xml Log: 16859 Can't supply a javax.mail.Session to Commons Email componenet Revision Changes Path 1.19 +31 -19 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- Email.java 18 Oct 2004 20:59:11 -0000 1.18 +++ Email.java 24 Oct 2004 17:41:21 -0000 1.19 @@ -127,6 +127,9 @@ /** Sent date */ protected Date sentDate = null; + + /** The Session to mail with */ + private Session session = null; /** * Instance of an <code>Authenticator</code> object that will be used @@ -310,6 +313,14 @@ } /** + * Supply a mail Session object to use + * + */ + public void setMailSession(Session session) + { + this.session = session; + } + /** * Initialise a mailsession object * * @return A Session. @@ -318,30 +329,31 @@ private Session getMailSession() throws MessagingException { - Properties properties = System.getProperties(); - properties.setProperty( MAIL_TRANSPORT_PROTOCOL, SMTP ); + if (session == null){ + Properties properties = System.getProperties(); + properties.setProperty( MAIL_TRANSPORT_PROTOCOL, SMTP ); - if ( !StringUtils.isNotEmpty( this.hostName ) ) - { - this.hostName = properties.getProperty( MAIL_HOST ); - } + if ( !StringUtils.isNotEmpty( this.hostName ) ) + { + this.hostName = properties.getProperty( MAIL_HOST ); + } - if ( !StringUtils.isNotEmpty( this.hostName ) ) - { - throw new MessagingException( "Cannot find valid hostname for mail session" ); - } + if ( !StringUtils.isNotEmpty( this.hostName ) ) + { + throw new MessagingException( "Cannot find valid hostname for mail session" ); + } - properties.setProperty( MAIL_PORT, smtpPort ); - properties.setProperty( MAIL_HOST, hostName ); - properties.setProperty( MAIL_DEBUG, String.valueOf( this.debug ) ); + properties.setProperty( MAIL_PORT, smtpPort ); + properties.setProperty( MAIL_HOST, hostName ); + properties.setProperty( MAIL_DEBUG, String.valueOf( this.debug ) ); - if ( this.authenticator != null ) - { + if ( this.authenticator != null ) + { properties.setProperty( MAIL_SMTP_AUTH, "true" ); - } - - Session session = Session.getDefaultInstance( properties, this.authenticator ); + } + Session session = Session.getDefaultInstance( properties, this.authenticator ); + } return session; } 1.5 +3 -0 jakarta-commons-sandbox/email/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/email/xdocs/changes.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- changes.xml 24 Oct 2004 17:27:21 -0000 1.4 +++ changes.xml 24 Oct 2004 17:41:21 -0000 1.5 @@ -7,6 +7,9 @@ <body> <release version="1.0" date="IN CVS"> + <action dev="epugh" type="add" issue="16859"> + Can't supply a javax.mail.Session to Commons Email componenet + </action> <action dev="epugh" type="add" issue="30973" due-to="Corey Scott"> HTML email with plain text alternative and attachments </action>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]