org.apache.james.transport.mailets
Class AbstractRedirect

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.AbstractRedirect
All Implemented Interfaces:
Mailet, MailetConfig
Direct Known Subclasses:
AbstractNotify, Forward, Redirect, Resend

public abstract class AbstractRedirect
extends GenericMailet

Abstract mailet providing configurable redirection services.
This mailet can be subclassed to make authoring redirection mailets simple.
By extending it and overriding one or more of these methods new behaviour can be quickly created without the author having to address any other issue than the relevant one:

For each of the methods above (generically called "getX()" methods in this class and its subclasses), there is an associated "getX(Mail)" method and most times a "setX(Mail, Tx, Mail)" method.
The roles are the following:

Here follows the typical pattern of those methods:


    ...
    Tx x;
    ...
    protected boolean getX(Mail originalMail) throws MessagingException {
        boolean x = (isStatic()) ? this.x : getX();
        ...
        return x;
    }
    ...
    public void init() throws MessagingException {
        ...
        isStatic = (getInitParameter("static") == null) ? false : new Boolean(getInitParameter("static")).booleanValue();
        if(isStatic()) {
            ...
            X  = getX();
            ...
        }
    ...
    public void service(Mail originalMail) throws MessagingException {
    ...
    setX(newMail, getX(originalMail), originalMail);
    ...
    }
    ...
 

The isStatic variable and method is used to allow for the situations (deprecated since version 2.2, but possibly used by previoulsy written extensions to Redirect) in which the getX() methods are non static: in this case isStatic() must return false.
Finally, a "getX()" method may return a "special address" (see AbstractRedirect.SpecialAddress), that later will be resolved ("late bound") by a "getX(Mail)" or "setX(Mail, Tx, Mail)": it is a dynamic value that does not require isStatic to be false.

Supports by default the passThrough init parameter (false if missing). Subclasses can override this behaviour overriding getPassThrough().

Since:
2.2.0
Version:
CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $

Nested Class Summary
protected static class AbstractRedirect.SpecialAddress
          Class containing "special addresses" constants.
 
Field Summary
protected static int ALL
           
protected static int BODY
           
protected static int HEADS
           
protected  boolean isDebug
          Controls certain log messages.
protected  boolean isStatic
          Holds the value of the static init parameter.
protected static int MESSAGE
           
protected static int NONE
           
protected static int UNALTERED
           
 
Constructor Summary
AbstractRedirect()
           
 
Method Summary
protected  boolean attachError()
          Gets the attachError property.
protected  boolean attachError(Mail originalMail)
          Gets the attachError property, built dynamically using the original Mail object.
protected  void buildAlteredMessage(Mail newMail, Mail originalMail)
          Builds the message of the newMail in case it has to be altered.
static void changeSubject(javax.mail.internet.MimeMessage message, java.lang.String newValue)
          It changes the subject of the supplied message to to supplied value but it also tries to preserve the original charset information.
protected  java.lang.String[] getAllowedInitParameters()
          Gets the expected init parameters.
protected  int getAttachmentType()
          Gets the attachment property.
protected  int getAttachmentType(Mail originalMail)
          Gets the attachment property, built dynamically using the original Mail object.
protected  boolean getFakeDomainCheck()
          Gets the fakeDomainCheck property.
protected  boolean getFakeDomainCheck(Mail originalMail)
          Gets the fakeDomainCheck property, built dynamically using the original Mail object.
protected  int getInLineType()
          Gets the inline property.
protected  int getInLineType(Mail originalMail)
          Gets the inline property, built dynamically using the original Mail object.
protected  java.lang.String getMessage()
          Gets the message property.
protected  java.lang.String getMessage(Mail originalMail)
          Gets the message property, built dynamically using the original Mail object.
protected  java.lang.String getMessageHeaders(javax.mail.internet.MimeMessage message)
          Utility method for obtaining a string representation of a Message's headers
protected  boolean getPassThrough()
          Gets the passThrough property.
protected  boolean getPassThrough(Mail originalMail)
          Gets the passThrough property, built dynamically using the original Mail object.
protected  java.util.Collection getRecipients()
          Gets the recipients property.
protected  java.util.Collection getRecipients(Mail originalMail)
          Gets the recipients property, built dynamically using the original Mail object.
protected  MailAddress getReplyTo()
          Gets the replyto property.
protected  MailAddress getReplyTo(Mail originalMail)
          Gets the replyTo property, built dynamically using the original Mail object.
protected  MailAddress getReversePath()
          Gets the reversePath property.
protected  MailAddress getReversePath(Mail originalMail)
          Gets the reversePath property, built dynamically using the original Mail object.
protected  MailAddress getSender()
          Gets the sender property.
protected  MailAddress getSender(Mail originalMail)
          Gets the sender property, built dynamically using the original Mail object.
protected  MailAddress getSpecialAddress(java.lang.String addressString, java.lang.String[] allowedSpecials)
          Returns the AbstractRedirect.SpecialAddress that corresponds to an init parameter value.
protected  java.lang.String getSubject()
          Gets the subject property.
protected  java.lang.String getSubject(Mail originalMail)
          Gets the subject property, built dynamically using the original Mail object.
protected  java.lang.String getSubjectPrefix()
          Gets the prefix property.
protected  java.lang.String getSubjectPrefix(Mail originalMail)
          Gets the subjectPrefix property, built dynamically using the original Mail object.
protected  javax.mail.internet.InternetAddress[] getTo()
          Gets the to property.
protected  javax.mail.internet.InternetAddress[] getTo(Mail originalMail)
          Gets the to property, built dynamically using the original Mail object.
protected  int getTypeCode(java.lang.String param)
          A private method to convert types from string to int.
 void init()
          Mailet initialization routine.
protected  boolean isReply()
          Gets the isReply property.
protected  boolean isReply(Mail originalMail)
          Gets the isReply property, built dynamically using the original Mail object.
protected  boolean isStatic()
          Gets the static property.
protected  java.util.Collection replaceInternetAddresses(Mail mail, java.util.Collection list)
          Returns a new Collection built over list replacing special addresses with real InternetAddress-es.
protected  java.util.Collection replaceMailAddresses(Mail mail, java.util.Collection list)
          Returns a new Collection built over list replacing special addresses with real MailAddress-es.
protected  boolean senderDomainIsValid(Mail mail)
          Checks if a sender domain of mail is valid.
 void service(Mail originalMail)
          Service does the hard work,and redirects the originalMail in the form specified.
protected  void setIsReply(Mail newMail, boolean isReply, Mail originalMail)
          Sets the "In-Reply-To:" header of newMail to the "Message-Id:" of originalMail, if isReply is true.
protected  void setRecipients(Mail newMail, java.util.Collection recipients, Mail originalMail)
          Sets the recipients of newMail to recipients.
protected  void setReplyTo(Mail newMail, MailAddress replyTo, Mail originalMail)
          Sets the "Reply-To:" header of newMail to replyTo.
protected  void setReversePath(MailImpl newMail, MailAddress reversePath, Mail originalMail)
          Sets the "reverse-path" of newMail to reversePath.
protected  void setSender(Mail newMail, MailAddress sender, Mail originalMail)
          Sets the "From:" header of newMail to sender.
protected  void setSubjectPrefix(Mail newMail, java.lang.String subjectPrefix, Mail originalMail)
          Builds the subject of newMail appending the subject of originalMail to subjectPrefix.
protected  void setTo(Mail newMail, javax.mail.internet.InternetAddress[] to, Mail originalMail)
          Sets the "To:" header of newMail to to.
 
Methods inherited from class org.apache.mailet.GenericMailet
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetInfo, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isDebug

protected boolean isDebug
Controls certain log messages.


isStatic

protected boolean isStatic
Holds the value of the static init parameter.


UNALTERED

protected static final int UNALTERED
See Also:
Constant Field Values

HEADS

protected static final int HEADS
See Also:
Constant Field Values

BODY

protected static final int BODY
See Also:
Constant Field Values

ALL

protected static final int ALL
See Also:
Constant Field Values

NONE

protected static final int NONE
See Also:
Constant Field Values

MESSAGE

protected static final int MESSAGE
See Also:
Constant Field Values
Constructor Detail

AbstractRedirect

public AbstractRedirect()
Method Detail

getAllowedInitParameters

protected java.lang.String[] getAllowedInitParameters()
Gets the expected init parameters.

Returns:
null meaning no check

isStatic

protected boolean isStatic()

Gets the static property.

Return true to reduce calls to getTo, getSender, getRecipients, getReplyTo, getReversePath amd getMessage where these values don't change (eg hard coded, or got at startup from the mailet config); return false where any of these methods generate their results dynamically eg in response to the message being processed, or by reference to a repository of users.

It is now (from version 2.2) somehow obsolete, as should be always true because the "good practice" is to use "getX()" methods statically, and use instead "getX(Mail)" methods for dynamic situations. A false value is now meaningful only for subclasses of Redirect older than version 2.2 that were relying on this.

Is a "getX()" method.

Returns:
true, as normally "getX()" methods shouls be static

getPassThrough

protected boolean getPassThrough()
                          throws javax.mail.MessagingException
Gets the passThrough property. Return true to allow the original message to continue through the processor, false to GHOST it. Is a "getX()" method.

Returns:
the passThrough init parameter, or false if missing
Throws:
javax.mail.MessagingException

getPassThrough

protected boolean getPassThrough(Mail originalMail)
                          throws javax.mail.MessagingException
Gets the passThrough property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getPassThrough()
Throws:
javax.mail.MessagingException

getFakeDomainCheck

protected boolean getFakeDomainCheck()
                              throws javax.mail.MessagingException
Gets the fakeDomainCheck property. Return true to check if the sender domain is valid. Is a "getX()" method.

Returns:
the fakeDomainCheck init parameter, or true if missing
Throws:
javax.mail.MessagingException

getFakeDomainCheck

protected boolean getFakeDomainCheck(Mail originalMail)
                              throws javax.mail.MessagingException
Gets the fakeDomainCheck property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getFakeDomainCheck()
Throws:
javax.mail.MessagingException

getInLineType

protected int getInLineType()
                     throws javax.mail.MessagingException
Gets the inline property. May return one of the following values to indicate how to append the original message to build the new message: Is a "getX()" method.

Returns:
the inline init parameter, or UNALTERED if missing
Throws:
javax.mail.MessagingException

getInLineType

protected int getInLineType(Mail originalMail)
                     throws javax.mail.MessagingException
Gets the inline property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getInLineType()
Throws:
javax.mail.MessagingException

getAttachmentType

protected int getAttachmentType()
                         throws javax.mail.MessagingException
Gets the attachment property. May return one of the following values to indicate how to attach the original message to the new message: Is a "getX()" method.

Returns:
the attachment init parameter, or NONE if missing
Throws:
javax.mail.MessagingException

getAttachmentType

protected int getAttachmentType(Mail originalMail)
                         throws javax.mail.MessagingException
Gets the attachment property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getAttachmentType()
Throws:
javax.mail.MessagingException

getMessage

protected java.lang.String getMessage()
                               throws javax.mail.MessagingException
Gets the message property. Returns a message to which the original message can be attached/appended to build the new message. Is a "getX()" method.

Returns:
the message init parameter or an empty string if missing
Throws:
javax.mail.MessagingException

getMessage

protected java.lang.String getMessage(Mail originalMail)
                               throws javax.mail.MessagingException
Gets the message property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getMessage()
Throws:
javax.mail.MessagingException

getRecipients

protected java.util.Collection getRecipients()
                                      throws javax.mail.MessagingException
Gets the recipients property. Returns the collection of recipients of the new message, or null if no change is requested. Is a "getX()" method.

Returns:
the recipients init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.FROM or SpecialAddress.REPLY_TO or SpecialAddress.REVERSE_PATH or SpecialAddress.UNALTERED or SpecialAddress.RECIPIENTS or null if missing
Throws:
javax.mail.MessagingException

getRecipients

protected java.util.Collection getRecipients(Mail originalMail)
                                      throws javax.mail.MessagingException
Gets the recipients property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
replaceMailAddresses(org.apache.mailet.Mail, java.util.Collection) on getRecipients(),
Throws:
javax.mail.MessagingException

setRecipients

protected void setRecipients(Mail newMail,
                             java.util.Collection recipients,
                             Mail originalMail)
                      throws javax.mail.MessagingException
Sets the recipients of newMail to recipients. If the requested value is null does nothing. Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

getTo

protected javax.mail.internet.InternetAddress[] getTo()
                                               throws javax.mail.MessagingException
Gets the to property. Returns the "To:" recipients of the new message. or null if no change is requested. Is a "getX()" method.

Returns:
the to init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.REVERSE_PATH or SpecialAddress.FROM or SpecialAddress.REPLY_TO or SpecialAddress.UNALTERED or SpecialAddress.TO or null if missing
Throws:
javax.mail.MessagingException

getTo

protected javax.mail.internet.InternetAddress[] getTo(Mail originalMail)
                                               throws javax.mail.MessagingException
Gets the to property, built dynamically using the original Mail object. Its outcome will be the the value the TO: header will be set to, that could be different from the real recipient (see getRecipients()). Is a "getX(Mail)" method.

Returns:
replaceInternetAddresses(org.apache.mailet.Mail, java.util.Collection) on getRecipients(),
Throws:
javax.mail.MessagingException

setTo

protected void setTo(Mail newMail,
                     javax.mail.internet.InternetAddress[] to,
                     Mail originalMail)
              throws javax.mail.MessagingException
Sets the "To:" header of newMail to to. If the requested value is null does nothing. Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

getReplyTo

protected MailAddress getReplyTo()
                          throws javax.mail.MessagingException
Gets the replyto property. Returns the Reply-To address of the new message, or null if no change is requested. Is a "getX()" method.

Returns:
the replyto init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.UNALTERED or SpecialAddress.NULL or null if missing
Throws:
javax.mail.MessagingException

getReplyTo

protected MailAddress getReplyTo(Mail originalMail)
                          throws javax.mail.MessagingException
Gets the replyTo property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getReplyTo() replacing SpecialAddress.UNALTERED if applicable with null and SpecialAddress.SENDER with the original mail sender
Throws:
javax.mail.MessagingException

setReplyTo

protected void setReplyTo(Mail newMail,
                          MailAddress replyTo,
                          Mail originalMail)
                   throws javax.mail.MessagingException

Sets the "Reply-To:" header of newMail to replyTo.

If the requested value is SpecialAddress.NULL will remove the "Reply-To:" header. If the requested value is null does nothing.

Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

getReversePath

protected MailAddress getReversePath()
                              throws javax.mail.MessagingException
Gets the reversePath property. Returns the reverse-path of the new message, or null if no change is requested. Is a "getX()" method.

Returns:
the reversePath init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.NULL or SpecialAddress.UNALTERED or null if missing
Throws:
javax.mail.MessagingException

getReversePath

protected MailAddress getReversePath(Mail originalMail)
                              throws javax.mail.MessagingException
Gets the reversePath property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getReversePath(), replacing SpecialAddress.SENDER if applicable with null, replacing SpecialAddress.UNALTERED and SpecialAddress.REVERSE_PATH if applicable with null, but not replacing SpecialAddress.NULL that will be handled by setReversePath(org.apache.james.core.MailImpl, org.apache.mailet.MailAddress, org.apache.mailet.Mail)
Throws:
javax.mail.MessagingException

setReversePath

protected void setReversePath(MailImpl newMail,
                              MailAddress reversePath,
                              Mail originalMail)
                       throws javax.mail.MessagingException
Sets the "reverse-path" of newMail to reversePath. If the requested value is SpecialAddress.NULL sets it to "<>". If the requested value is null does nothing. Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

getSender

protected MailAddress getSender()
                         throws javax.mail.MessagingException
Gets the sender property. Returns the new sender as a MailAddress, or null if no change is requested. Is a "getX()" method.

Returns:
the sender init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.UNALTERED or null if missing
Throws:
javax.mail.MessagingException

getSender

protected MailAddress getSender(Mail originalMail)
                         throws javax.mail.MessagingException
Gets the sender property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getSender() replacing SpecialAddress.UNALTERED and SpecialAddress.SENDER if applicable with null
Throws:
javax.mail.MessagingException

setSender

protected void setSender(Mail newMail,
                         MailAddress sender,
                         Mail originalMail)
                  throws javax.mail.MessagingException
Sets the "From:" header of newMail to sender. If the requested value is null does nothing. Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

getSubject

protected java.lang.String getSubject()
                               throws javax.mail.MessagingException
Gets the subject property. Returns a string for the new message subject. Is a "getX()" method.

Returns:
the subject init parameter or null if missing
Throws:
javax.mail.MessagingException

getSubject

protected java.lang.String getSubject(Mail originalMail)
                               throws javax.mail.MessagingException
Gets the subject property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getSubject()
Throws:
javax.mail.MessagingException

getSubjectPrefix

protected java.lang.String getSubjectPrefix()
                                     throws javax.mail.MessagingException
Gets the prefix property. Returns a prefix for the new message subject. Is a "getX()" method.

Returns:
the prefix init parameter or an empty string if missing
Throws:
javax.mail.MessagingException

getSubjectPrefix

protected java.lang.String getSubjectPrefix(Mail originalMail)
                                     throws javax.mail.MessagingException
Gets the subjectPrefix property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
getSubjectPrefix()
Throws:
javax.mail.MessagingException

setSubjectPrefix

protected void setSubjectPrefix(Mail newMail,
                                java.lang.String subjectPrefix,
                                Mail originalMail)
                         throws javax.mail.MessagingException
Builds the subject of newMail appending the subject of originalMail to subjectPrefix. Is a "setX(Mail, Tx, Mail)" method.

Throws:
javax.mail.MessagingException

attachError

protected boolean attachError()
                       throws javax.mail.MessagingException
Gets the attachError property. Returns a boolean indicating whether to append a description of any error to the main body part of the new message, if getInlineType does not return "UNALTERED". Is a "getX()" method.

Returns:
the attachError init parameter; false if missing
Throws:
javax.mail.MessagingException

attachError

protected boolean attachError(Mail originalMail)
                       throws javax.mail.MessagingException
Gets the attachError property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
attachError()
Throws:
javax.mail.MessagingException

isReply

protected boolean isReply()
                   throws javax.mail.MessagingException
Gets the isReply property. Returns a boolean indicating whether the new message must be considered a reply to the original message, setting the IN_REPLY_TO header of the new message to the id of the original message. Is a "getX()" method.

Returns:
the isReply init parameter; false if missing
Throws:
javax.mail.MessagingException

isReply

protected boolean isReply(Mail originalMail)
                   throws javax.mail.MessagingException
Gets the isReply property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Returns:
isReply()
Throws:
javax.mail.MessagingException

setIsReply

protected void setIsReply(Mail newMail,
                          boolean isReply,
                          Mail originalMail)
                   throws javax.mail.MessagingException
Sets the "In-Reply-To:" header of newMail to the "Message-Id:" of originalMail, if isReply is true.

Throws:
javax.mail.MessagingException

init

public void init()
          throws javax.mail.MessagingException
Mailet initialization routine. Will setup static values for each "x" initialization parameter in config.xml, using getX(), if isStatic() returns true.

Overrides:
init in class GenericMailet
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the mailet's normal operation

service

public void service(Mail originalMail)
             throws javax.mail.MessagingException
Service does the hard work,and redirects the originalMail in the form specified.

Specified by:
service in interface Mailet
Specified by:
service in class GenericMailet
Parameters:
originalMail - the mail to process and redirect
Throws:
javax.mail.MessagingException - if a problem arises formulating the redirected mail

getTypeCode

protected int getTypeCode(java.lang.String param)
A private method to convert types from string to int.

Parameters:
param - the string type
Returns:
the corresponding int enumeration

getMessageHeaders

protected java.lang.String getMessageHeaders(javax.mail.internet.MimeMessage message)
                                      throws javax.mail.MessagingException
Utility method for obtaining a string representation of a Message's headers

Throws:
javax.mail.MessagingException

buildAlteredMessage

protected void buildAlteredMessage(Mail newMail,
                                   Mail originalMail)
                            throws javax.mail.MessagingException
Builds the message of the newMail in case it has to be altered.

Parameters:
originalMail - the original Mail object
newMail - the Mail object to build
Throws:
javax.mail.MessagingException

getSpecialAddress

protected final MailAddress getSpecialAddress(java.lang.String addressString,
                                              java.lang.String[] allowedSpecials)
                                       throws javax.mail.MessagingException
Returns the AbstractRedirect.SpecialAddress that corresponds to an init parameter value. The init parameter value is checked against a String[] of allowed values. The checks are case insensitive.

Parameters:
addressString - the string to check if is a special address
allowedSpecials - a String[] with the allowed special addresses
Returns:
a SpecialAddress if found, null if not found or addressString is null
Throws:
javax.mail.MessagingException - if is a special address not in the allowedSpecials array

senderDomainIsValid

protected final boolean senderDomainIsValid(Mail mail)
                                     throws javax.mail.MessagingException

Checks if a sender domain of mail is valid.

If we do not do this check, and someone uses a redirection mailet in a processor initiated by SenderInFakeDomain, then a fake sender domain will cause an infinite loop (the forwarded e-mail still appears to come from a fake domain).
Although this can be viewed as a configuration error, the consequences of such a mis-configuration are severe enough to warrant protecting against the infinite loop.

This check can be skipped if getFakeDomainCheck(Mail) returns true.

Parameters:
mail - the mail object to check
Returns:
true if the if the sender is null or MailetContext.getMailServers(java.lang.String) returns true for the sender host part
Throws:
javax.mail.MessagingException

changeSubject

public static void changeSubject(javax.mail.internet.MimeMessage message,
                                 java.lang.String newValue)
                          throws javax.mail.MessagingException
It changes the subject of the supplied message to to supplied value but it also tries to preserve the original charset information.
This method was needed to avoid sending the subject using a charset (usually the default charset on the server) which doesn't contain the characters in the subject, resulting in the loss of these characters. The most simple method would be to either send it in ASCII unencoded or in UTF-8 if non-ASCII characters are present but unfortunately UTF-8 is not yet a MIME standard and not all email clients are supporting it. The optimal method would be to determine the best charset by analyzing the actual characters. That would require much more work (exept if an open source library already exists for this). However there is nothing to stop somebody to add a detection algorithm for a specific charset.
The current algorithm works correctly if only ASCII characters are added to an existing subject.
If the new value is ASCII only, then it doesn't apply any encoding to the subject header. (This is provided by MimeMessage.setSubject()).
Possible enhancement: under java 1.4 java.nio the system can determine if the suggested charset fits or not (if there is untranslatable characters). If the charset doesn't fit the new value, it can fall back to UTF-8.

Parameters:
message - the message of which subject is changed
newValue - the new (unencoded) value of the subject. It must not be null.
Throws:
javax.mail.MessagingException - - according to the JavaMail doc most likely this is never thrown

replaceMailAddresses

protected java.util.Collection replaceMailAddresses(Mail mail,
                                                    java.util.Collection list)
Returns a new Collection built over list replacing special addresses with real MailAddress-es.
Manages SpecialAddress.SENDER, SpecialAddress.REVERSE_PATH, SpecialAddress.FROM, SpecialAddress.REPLY_TO, SpecialAddress.RECIPIENTS, SpecialAddress.TO, SpecialAddress.NULL and SpecialAddress.UNALTERED.
SpecialAddress.FROM is made equivalent to SpecialAddress.SENDER; SpecialAddress.TO is made equivalent to SpecialAddress.RECIPIENTS.
SpecialAddress.REPLY_TO uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path.
SpecialAddress.NULL and SpecialAddress.UNALTERED are ignored.
Any other address is not replaced.


replaceInternetAddresses

protected java.util.Collection replaceInternetAddresses(Mail mail,
                                                        java.util.Collection list)
                                                 throws javax.mail.MessagingException
Returns a new Collection built over list replacing special addresses with real InternetAddress-es.
Manages SpecialAddress.SENDER, SpecialAddress.REVERSE_PATH, SpecialAddress.FROM, SpecialAddress.REPLY_TO, SpecialAddress.RECIPIENTS, SpecialAddress.TO, SpecialAddress.NULL and SpecialAddress.UNALTERED.
SpecialAddress.RECIPIENTS is made equivalent to SpecialAddress.TO.
SpecialAddress.FROM uses the From header if available, otherwise the Sender header if available, otherwise the return-path.
SpecialAddress.REPLY_TO uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path.
SpecialAddress.UNALTERED is ignored.
Any other address is not replaced.

Throws:
javax.mail.MessagingException


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.