diff --git a/ccm-core/src/com/arsdigita/mail/Mail.java b/ccm-core/src/com/arsdigita/mail/Mail.java index 6d624e7c3..9a1d68440 100755 --- a/ccm-core/src/com/arsdigita/mail/Mail.java +++ b/ccm-core/src/com/arsdigita/mail/Mail.java @@ -19,6 +19,7 @@ package com.arsdigita.mail; import com.arsdigita.util.MessageType; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -33,6 +34,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Properties; import java.util.StringTokenizer; + import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.activation.URLDataSource; @@ -45,28 +47,32 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; + import org.apache.log4j.Logger; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import javax.mail.PasswordAuthentication; + /** - * Represents a email message with optional attachments. This class - * is a wrapper for the JavaMail API that makes it easier for - * application developers to create and send email. For simple plain - * text message, there is a static convenience method that does not - * require the construction of an explicit Mail object: + * Represents a email message with optional attachments. This class is a wrapper + * for the JavaMail API that makes it easier for application developers to + * create and send email. For simple plain text message, there is a static + * convenience method that does not require the construction of an explicit Mail + * object: * *
  * Mail.send(to, from, subject, body)
  * 
* - *

For more complex messages, the API provides methods to set all - * standard mail headers, attach other pieces of content, and finally - * invoke the transport process to deliver the message. + *

+ * For more complex messages, the API provides methods to set all standard mail + * headers, attach other pieces of content, and finally invoke the transport + * process to deliver the message. * - * @author Ron Henderson + * @author Ron Henderson * @version $Id: Mail.java 994 2005-11-14 14:29:25Z apevec $ */ public class Mail implements MessageType { @@ -74,8 +80,7 @@ public class Mail implements MessageType { /** * Used for logging. */ - private static final Logger s_log = - Logger.getLogger(Mail.class); + private static final Logger s_log = Logger.getLogger(Mail.class); private static MailConfig s_config; public static MailConfig getConfig() { @@ -86,8 +91,9 @@ public class Mail implements MessageType { } return s_config; } - private static final InternetAddress[] EMPTY_ADDRESS_LIST = - new InternetAddress[0]; + + private static final InternetAddress[] EMPTY_ADDRESS_LIST + = new InternetAddress[0]; /** * Table of message headers. */ @@ -99,11 +105,13 @@ public class Mail implements MessageType { private InternetAddress[] m_filteredTo = EMPTY_ADDRESS_LIST; private InternetAddress[] m_invalidTo = EMPTY_ADDRESS_LIST; private static Set s_invalidDomains = new HashSet(); + static { s_log.debug("Static initalizer starting..."); s_invalidDomains.add("example.com"); s_log.debug("Static initalizer finished."); } + /** * Email address the message is being sent from. */ @@ -133,8 +141,8 @@ public class Mail implements MessageType { */ private String m_alternate; /** - * Encoding specification for m_body and m_alternate (optional). - * Default value (null) implies "us-ascii" encoding. + * Encoding specification for m_body and m_alternate (optional). Default + * value (null) implies "us-ascii" encoding. */ private String m_encoding; /** @@ -150,13 +158,13 @@ public class Mail implements MessageType { */ private static Session s_session; /** - * SMTP host to connect to. Only used to override the default for - * testing purposes. + * SMTP host to connect to. Only used to override the default for testing + * purposes. */ private static String s_host; /** - * SMTP port to connect to. Only used to override the default for - * testing purposes. + * SMTP port to connect to. Only used to override the default for testing + * purposes. */ private static String s_port; // Constants used by Mail @@ -174,8 +182,8 @@ public class Mail implements MessageType { public final static String ATTACHMENT = javax.mail.Part.ATTACHMENT; /** - * Default constructor. Must use the setTo, setSubject (and so on) - * methods to create a valid mail message. + * Default constructor. Must use the setTo, setSubject (and so on) methods + * to create a valid mail message. */ public Mail() { this(null, null, null, null); @@ -184,8 +192,8 @@ public class Mail implements MessageType { /** * Constructor used to specify to, from, and subject. * - * @param to one or more of addresses to send the message to - * @param from the address the message is being sent from + * @param to one or more of addresses to send the message to + * @param from the address the message is being sent from * @param subject the subject for the message */ public Mail(String to, @@ -197,10 +205,10 @@ public class Mail implements MessageType { /** * Constructor used to specify to, from, subject, and body. * - * @param to one or more of addresses to send the message to - * @param from the address the message is being sent from + * @param to one or more of addresses to send the message to + * @param from the address the message is being sent from * @param subject the subject for the message - * @param body the plain text body of the message + * @param body the plain text body of the message */ public Mail(String to, String from, @@ -214,14 +222,13 @@ public class Mail implements MessageType { } /** - * Constructor used to specify to, from, subject, body, and - * encoding. + * Constructor used to specify to, from, subject, body, and encoding. * - * @param to one or more of addresses to send the message to - * @param from the address the message is being sent from + * @param to one or more of addresses to send the message to + * @param from the address the message is being sent from * @param subject the subject for the message - * @param body is plain text body of the message - * @param enc the encoding of the body + * @param body is plain text body of the message + * @param enc the encoding of the body */ public Mail(String to, String from, @@ -235,27 +242,27 @@ public class Mail implements MessageType { /** * A convenience method to send a simple plain-text message. * - * @param to one or more of addresses to send the message to - * @param from the address the message is being sent from + * @param to one or more of addresses to send the message to + * @param from the address the message is being sent from * @param subject the subject for the message - * @param body the plain text body of the message + * @param body the plain text body of the message */ public static void send(String to, String from, String subject, String body) - throws MessagingException, - SendFailedException { + throws MessagingException, + SendFailedException { Mail msg = new Mail(to, from, subject, body); msg.send(); } - + /** * Sends the message. */ public void send() - throws MessagingException, - SendFailedException { + throws MessagingException, + SendFailedException { Transport transport = getSession().getTransport(); transport.connect(); send(transport); @@ -263,17 +270,18 @@ public class Mail implements MessageType { } /** - * Sends the message using a given Transport object (package-level - * access). This method is used when sending multiple messages at - * once with a single connection to the mail server. + * Sends the message using a given Transport object (package-level access). + * This method is used when sending multiple messages at once with a single + * connection to the mail server. * - * @throws SendFailedException on any kind of MessagingException, - * also such returned from the server. Applications might try - * to catch this and re-schedule sending the mail. + * @throws SendFailedException on any kind of MessagingException, also such + * returned from the server. Applications might + * try to catch this and re-schedule sending the + * mail. */ void send(Transport transport) - throws MessagingException, - SendFailedException { + throws MessagingException, + SendFailedException { Message msg = null; if (m_filteredTo.length > 0) { msg = getMessage(); @@ -284,7 +292,6 @@ public class Mail implements MessageType { // Close the transport agent and rethrow error for // detailed message. - transport.close(); throw new SendFailedException("send failed: ", mex); @@ -292,14 +299,13 @@ public class Mail implements MessageType { } // Write a copy of the message into the log file - if (getConfig().isDebug()) { if (msg != null) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); msg.writeTo(os); s_log.debug("message sent:\n" + os.toString() - + "\n-- EOT --"); + + "\n-- EOT --"); } catch (IOException ex) { s_log.error("unable to log message"); } @@ -308,15 +314,16 @@ public class Mail implements MessageType { } } else { s_log.info("message sent to <" + Arrays.asList(m_filteredTo) - + "> from <" + m_from + "> subject <" + m_subject + ">"); + + "> from <" + m_from + "> subject <" + m_subject + + ">"); s_log.info("messages filtered for <" + Arrays.asList(m_invalidTo) - + "> from <" + m_from + "> subject <" + m_subject + ">"); + + "> from <" + m_from + "> subject <" + m_subject + + ">"); } } /** - * Sets the email address that the message is being sent - * to. + * Sets the email address that the message is being sent to. * * @param to one or more addresses to send the message to */ @@ -326,8 +333,7 @@ public class Mail implements MessageType { } /** - * Sets the email address that the message is being sent - * from. + * Sets the email address that the message is being sent from. * * @param from the address the message is sent from */ @@ -374,7 +380,7 @@ public class Mail implements MessageType { /** * Adds a header (name, value) pair. * - * @param name the header element name + * @param name the header element name * @param value the header element value */ public void addHeader(String name, String value) { @@ -387,6 +393,7 @@ public class Mail implements MessageType { /** * Sets the email address that is being carbon-copied. + * * @param cc the email address for a carbon copy */ public void setCc(String cc) { @@ -395,6 +402,7 @@ public class Mail implements MessageType { /** * Sets the email address that is being blind carbon-copied. + * * @param bcc the email address for a blind carbon copy */ public void setBcc(String bcc) { @@ -403,6 +411,7 @@ public class Mail implements MessageType { /** * Sets the body of the email to a simple plain text message. + * * @param body the body of the message in plain text */ public void setBody(String body) { @@ -410,11 +419,11 @@ public class Mail implements MessageType { } /** - * Sets the body of the email to an HTML encoded message with a - * plain text alternative. + * Sets the body of the email to an HTML encoded message with a plain text + * alternative. * * @param body the body of the message in HTML - * @param alt the alternate message body in plain text + * @param alt the alternate message body in plain text */ public void setBody(String body, String alt) { m_body = body; @@ -432,8 +441,8 @@ public class Mail implements MessageType { } /** - * Returns the character encoding that is being used. The default - * is "us-ascii". + * Returns the character encoding that is being used. The default is + * "us-ascii". * * @return the string value of the character encoding being used */ @@ -442,14 +451,14 @@ public class Mail implements MessageType { } /** - * Adds an attachment to a message. This method is private but - * is invoked by all of the other attach methods once they've - * constructed an appropraite MimeBodyPart to attach. + * Adds an attachment to a message. This method is private but is invoked by + * all of the other attach methods once they've constructed an appropraite + * MimeBodyPart to attach. * * @param part the message part to attach */ private void attach(MimeBodyPart part) - throws MessagingException { + throws MessagingException { if (m_attachments == null) { m_attachments = new MimeMultipart(); } @@ -457,27 +466,26 @@ public class Mail implements MessageType { } /** - * Adds an attachment with a specified name and description to a - * message by fetching its content from a URL. Sets the - * disposition to ATTACHMENT. + * Adds an attachment with a specified name and description to a message by + * fetching its content from a URL. Sets the disposition to ATTACHMENT. * - * @param url the URL to retreieve the content from - * @param name the name of the attachment + * @param url the URL to retreieve the content from + * @param name the name of the attachment * @param description a description of the attachment */ public void attach(URL url, String name, String description) - throws MessagingException { + throws MessagingException { attach(url, name, description, Mail.ATTACHMENT); } /** - * Adds an attachment with a specified name, description and - * disposition to a message by fetching its content from a URL. + * Adds an attachment with a specified name, description and disposition to + * a message by fetching its content from a URL. * - * @param url the URL to retreieve the content from - * @param name the name of the attachment + * @param url the URL to retreieve the content from + * @param name the name of the attachment * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ @@ -485,7 +493,7 @@ public class Mail implements MessageType { String name, String description, String disposition) - throws MessagingException { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -498,28 +506,27 @@ public class Mail implements MessageType { } /** - * Adds an attachment with a specified name and description to a - * message by fetching its content from a local file. Sets the - * disposition to ATTACHMENT. + * Adds an attachment with a specified name and description to a message by + * fetching its content from a local file. Sets the disposition to + * ATTACHMENT. * - * @param path the file path to retreieve the content from - * @param name the name of the attachment + * @param path the file path to retreieve the content from + * @param name the name of the attachment * @param description a description of the attachment */ public void attach(File path, String name, String description) - throws MessagingException { + throws MessagingException { attach(path, name, description, ATTACHMENT); } /** - * Adds an attachment with a specified name, description and - * disposition to a message by fetching its content from a - * local file. + * Adds an attachment with a specified name, description and disposition to + * a message by fetching its content from a local file. * - * @param path the file path to retreieve the content from - * @param name the name of the attachment + * @param path the file path to retreieve the content from + * @param name the name of the attachment * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ @@ -527,7 +534,7 @@ public class Mail implements MessageType { String name, String description, String disposition) - throws MessagingException { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -540,100 +547,98 @@ public class Mail implements MessageType { } /** - * Attaches a byte array to a message. Sets the MIME type and - * name of the attachment, and initializes its disposition to + * Attaches a byte array to a message. Sets the MIME type and name of the + * attachment, and initializes its disposition to ATTACHMENT. + * + * @param data the content of the attachment + * @param type the MIME type of the attachment + * @param name the name of the attachment + */ + public void attach(byte[] data, + String type, + String name) + throws MessagingException { + attach(data, type, name, null, ATTACHMENT); + } + + /** + * Attaches a byte array to a message. Sets the MIME type, name, description + * and disposition of the attachment. + * + * @param data the content of the attachment + * @param type the MIME type of the attachment + * @param name the name of the attachment + * @param description a description of the attachment + * @param disposition Mail.ATTACHMENT or Mail.INLINE + */ + public void attach(byte[] data, + String type, + String name, + String description, + String disposition) + throws MessagingException { + ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); + attach(ds, description, disposition); + } + + /** + * Attaches a String to a message. Sets the MIME type and name of the + * attachment, and initializes the disposition to ATTACHMENT. + * + * @param data the content of the attachment + * @param type the MIME type of the attachment + * @param name the name of the attachment + */ + public void attach(String data, + String type, + String name) + throws MessagingException { + attach(data, type, name, null, ATTACHMENT); + } + + /** + * Attaches a String to a message. Sets the MIME type, name, description and + * disposition of the attachment. + * + * @param data the content of the attachment + * @param type the MIME type of the attachment + * @param name the name of the attachment + * @param description a description of the attachment + * @param disposition Mail.ATTACHMENT or Mail.INLINE + */ + public void attach(String data, + String type, + String name, + String description, + String disposition) + throws MessagingException { + ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); + attach(ds, description, disposition); + } + + /** + * Attaches the content from a ByteArrayInputStream to a message. Sets the + * MIME type and name of the attachment, and initializes the disposition to * ATTACHMENT. * - * @param data the content of the attachment - * @param type the MIME type of the attachment - * @param name the name of the attachment - */ - public void attach(byte[] data, - String type, - String name) - throws MessagingException { - attach(data, type, name, null, ATTACHMENT); - } - - /** - * Attaches a byte array to a message. Sets the MIME type, name, - * description and disposition of the attachment. - * - * @param data the content of the attachment - * @param type the MIME type of the attachment - * @param name the name of the attachment - * @param description a description of the attachment - * @param disposition Mail.ATTACHMENT or Mail.INLINE - */ - public void attach(byte[] data, - String type, - String name, - String description, - String disposition) - throws MessagingException { - ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); - attach(ds, description, disposition); - } - - /** - * Attaches a String to a message. Sets the MIME type and name of - * the attachment, and initializes the disposition to ATTACHMENT. - * - * @param data the content of the attachment - * @param type the MIME type of the attachment - * @param name the name of the attachment - */ - public void attach(String data, - String type, - String name) - throws MessagingException { - attach(data, type, name, null, ATTACHMENT); - } - - /** - * Attaches a String to a message. Sets the MIME type, name, - * description and disposition of the attachment. - * - * @param data the content of the attachment - * @param type the MIME type of the attachment - * @param name the name of the attachment - * @param description a description of the attachment - * @param disposition Mail.ATTACHMENT or Mail.INLINE - */ - public void attach(String data, - String type, - String name, - String description, - String disposition) - throws MessagingException { - ByteArrayDataSource ds = new ByteArrayDataSource(data, type, name); - attach(ds, description, disposition); - } - - /** - * Attaches the content from a ByteArrayInputStream to a message. - * Sets the MIME type and name of the attachment, and initializes - * the disposition to ATTACHMENT. - * - * @param is the input stream to read from. + * @param is the input stream to read from. * @param type the MIME type of the attachment * @param name the name of the attachment */ public void attach(ByteArrayInputStream is, String type, String name) - throws MessagingException { + throws MessagingException { attach(is, type, name, null, ATTACHMENT); } /** - * Attaches the content from a ByteArrayInputStream to a message. - * Sets the MIME type, name, description and disposition of the - * attachment. + * Attaches the content from a ByteArrayInputStream to a message. Sets the + * MIME type, name, description and disposition of the attachment. * - * @param is the input stream to read from. - * @param type the MIME type of the attachment - * @param name the name of the attachment + * @param is the input stream to read from. + * @param type the MIME type of the attachment + * @param name the name of the attachment * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ @@ -642,25 +647,25 @@ public class Mail implements MessageType { String name, String description, String disposition) - throws MessagingException { + throws MessagingException { ByteArrayDataSource ds = new ByteArrayDataSource(is, type, name); attach(ds, description, disposition); } /** - * Attaches the content from a ByteArrayDataSource to a - * message. This is used internally by various other methods that - * take higher-level object types as input. The MIME type and - * name are determined directly from the dataSource. + * Attaches the content from a ByteArrayDataSource to a message. This is + * used internally by various other methods that take higher-level object + * types as input. The MIME type and name are determined directly from the + * dataSource. * - * @param dataSource the data source to read from - * @param description a description of the attachment + * @param dataSource the data source to read from + * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ protected void attach(ByteArrayDataSource dataSource, String description, String disposition) - throws MessagingException { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -673,29 +678,29 @@ public class Mail implements MessageType { } /** - * Attaches content to a message by supplying a DataHandler. All - * relevant parameters (MIME type, name, ...) are determined - * directly from the DataHandler. + * Attaches content to a message by supplying a DataHandler. All relevant + * parameters (MIME type, name, ...) are determined directly from the + * DataHandler. * * @param dh a DataHandler for some piece of content. */ public void attach(DataHandler dh) - throws MessagingException { + throws MessagingException { attach(dh, null, ATTACHMENT); } /** - * Attaches content to a message by supplying a DataHandler. Sets - * the description and disposition of the content. + * Attaches content to a message by supplying a DataHandler. Sets the + * description and disposition of the content. * - * @param dh the data source to read from + * @param dh the data source to read from * @param description a description of the attachment * @param disposition Mail.ATTACHMENT or Mail.INLINE */ public void attach(DataHandler dh, String description, String disposition) - throws MessagingException { + throws MessagingException { MimeBodyPart part = new MimeBodyPart(); attach(part); @@ -706,17 +711,16 @@ public class Mail implements MessageType { } /** - * Utility function that returns an appropriate Session object for - * sending mail. This uses the default properties from the Mail - * initializer and any of properties that can be overridden at - * the package level. + * Utility function that returns an appropriate Session object for sending + * mail. This uses the default properties from the Mail initializer and any + * of properties that can be overridden at the package level. */ static synchronized Session getSession() { if (s_session == null) { // Set up the properties - Properties props = new Properties(getConfig().getJavamail()); + final Properties props = new Properties(getConfig().getJavamail()); // Check for overrides of the server information if (s_host != null) { @@ -727,7 +731,22 @@ public class Mail implements MessageType { } // Set up the session - s_session = Session.getInstance(props, null); + if (props.getProperty("mail.user") != null) { + s_session = Session.getInstance( + props, + new javax.mail.Authenticator() { + + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication( + props.getProperty("mail.user"), + props.getProperty("mail.password")); + } + + }); + } else { + s_session = Session.getInstance(props, null); + } s_session.setDebug(getConfig().isDebug()); } @@ -735,13 +754,13 @@ public class Mail implements MessageType { } /** - * Utility function that returns the message part of the mail. - * Useful if you want to build a separate Transport process (for - * example, to queue a number of messages to send all at once rather - * than invoke the Mail.send() method for each instance.) + * Utility function that returns the message part of the mail. Useful if you + * want to build a separate Transport process (for example, to queue a + * number of messages to send all at once rather than invoke the Mail.send() + * method for each instance.) */ private Message getMessage() - throws MessagingException { + throws MessagingException { // Create the message MimeMessage msg = new MimeMessage(getSession()); @@ -796,14 +815,13 @@ public class Mail implements MessageType { } // Return the Message object with it's content ready to go. - return prepareMessageContent(msg); } /** - * Sets the host and port to connect to when sending - * mail. Package-level access (should only be used for testing). + * Sets the host and port to connect to when sending mail. Package-level + * access (should only be used for testing). * * @param host the SMTP host to connect to * @param port the port number on that host @@ -818,6 +836,7 @@ public class Mail implements MessageType { /** * Returns the SMTP mail host for debugging and account information. + * * @return the SMTP mail host for debugging and account information. */ public synchronized static String getSmtpServer() { @@ -825,13 +844,13 @@ public class Mail implements MessageType { } /** - * Writes the content of the message to the given output stream. - * Useful for debugging. + * Writes the content of the message to the given output stream. Useful for + * debugging. * * @param os the output stream to write the message to */ public void writeTo(OutputStream os) - throws MessagingException { + throws MessagingException { try { getMessage().writeTo(os); } catch (IOException ex) { @@ -953,7 +972,7 @@ public class Mail implements MessageType { * Utility function to prepare the content of the message. */ private Message prepareMessageContent(MimeMessage msg) - throws MessagingException { + throws MessagingException { if (m_alternate == null && m_attachments == null) { // We have a plain-text message with no attachments. Use @@ -966,24 +985,20 @@ public class Mail implements MessageType { // For anything else the message will be a MIME multipart, // with a subtype of of either "mixed" or "alternative" // depending on whether we have attachments. - String subtype = (m_attachments == null) ? ALTERNATIVE : MIXED; // Create a MIME multipart for the content. - MimeMultipart mp = new MimeMultipart(subtype); msg.setContent(mp); // Next we need to look at whether the message part of the // content is going to be text/plain or text/html. - MimeBodyPart part = new MimeBodyPart(); if (m_alternate == null) { // No alternate, so it must be text/plain with // attachments. - part.setText(m_body, m_encoding); part.setHeader(CONTENT_TYPE, MessageType.TEXT_PLAIN); mp.addBodyPart(part); @@ -994,12 +1009,10 @@ public class Mail implements MessageType { // the first part and the alternate as the second. // The overall MIME subtype is probably ALTERNATE // (depending on whether we have attachments). - part.setText(m_body, m_encoding); part.setHeader(CONTENT_TYPE, MessageType.TEXT_HTML); mp.addBodyPart(part); - part = new MimeBodyPart(); part.setText(m_alternate, m_encoding); part.setHeader(CONTENT_TYPE, MessageType.TEXT_PLAIN); @@ -1010,11 +1023,9 @@ public class Mail implements MessageType { // Do we have attachments? If so then the MIME subtype // must be MIXED and and the attachments need to be // transferred to the Message. - if (m_attachments != null) { // Add attachments to the Message content. - for (int i = 0; i < m_attachments.getCount(); i++) { mp.addBodyPart(m_attachments.getBodyPart(i)); } @@ -1023,14 +1034,13 @@ public class Mail implements MessageType { // Save changes to the message. This will update the MIME // headers so the message is ready to send. - msg.saveChanges(); return msg; } /** - * + * */ private InternetAddress[] filterRecipients() { ArrayList filtered = new ArrayList(); @@ -1049,13 +1059,16 @@ public class Mail implements MessageType { } else { invalid.add(m_to[i]); s_log.debug("filtering message to non-existent email address " - + m_to[i]); + + m_to[i]); } } - m_filteredTo = (InternetAddress[]) filtered.toArray(new InternetAddress[filtered. - size()]); - m_invalidTo = (InternetAddress[]) invalid.toArray(new InternetAddress[invalid. - size()]); + m_filteredTo = (InternetAddress[]) filtered.toArray( + new InternetAddress[filtered. + size()]); + m_invalidTo = (InternetAddress[]) invalid.toArray( + new InternetAddress[invalid. + size()]); return m_filteredTo; } + }