There is no need to change any code, the current version of SMTPAppender
available in log4j1.2.x already accepts multiple email addresses.  Here is
an example snippet from my app's configuration property file (with email
addresses changed to protect the innocent).

[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]

This sets the To property of the SMTPAppender, and if you read the JavaDoc
for the SMTPAppender.setTo(String) method, it says:

     The <b>To</b> option takes a string value which should be a
     comma separated list of e-mail address of the recipients.

You will notice in the code you cite, that it calls the parseAddress
internal method which returns an array of addresses from the csv string.

cheers,

Paul Smith

> -----Original Message-----
> From: harsha bhogle [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, 12 May 2004 7:39 AM
> To: Log4J Users List
> Subject: mutilple email addresses using SMTPAppender
> 
> 
> Hi Guys,
> I am curious If there is a way to change the SMTPAppender to 
> accept multiple "To" email address, which is the default way 
> it works. Does anyone has implemented this?
> The method activateOptions seems to set the information for 
> sending..Should I be extending this class and overwrite this 
> method, to accept mutiple email address.?
> Thanks
>  
>  public void activateOptions()
>     {
>         Properties properties = new 
> Properties(System.getProperties());
>         if(smtpHost != null)
>             properties.put("mail.smtp.host", smtpHost);
>         Session session = Session.getInstance(properties, null);
>         msg = new MimeMessage(session);
>         try
>         {
>             if(from != null)
>                 msg.setFrom(getAddress(from));
>             else
>                 msg.setFrom();
>             
> msg.setRecipients(javax.mail.Message.RecipientType.TO, 
> parseAddress(to));
>             if(subject != null)
>                 msg.setSubject(subject);
>         }
>         catch(MessagingException messagingexception)
>         {
>             LogLog.error("Could not activate SMTPAppender 
> options.", messagingexception);
>         }
>     }
>  
> 
>               
> ---------------------------------
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to