FileDocCategorySizeDatePackage
Forward.javaAPI DocApache James 2.3.16828Fri Jan 12 12:56:28 GMT 2007org.apache.james.transport.mailets

Forward

public class Forward extends AbstractRedirect

Replaces incoming recipients with those specified, and resends the message unaltered.

Can be totally replaced by an equivalent usage of {@link Resend} (see below), simply replacing <forwardto> with <recipients>.

Sample configuration:


<mailet match="All" class="Forward">
<forwardTo>comma delimited list of email addresses</forwardTo>
<passThrough>true or false, default=false</passThrough>
<fakeDomainCheck>true or false, default=true</fakeDomainCheck>
<debug>true or false, default=false</debug>
</mailet>

The behaviour of this mailet is equivalent to using Resend with the following configuration:


<mailet match="All" class="Resend">
<recipients>comma delimited list of email addresses</recipients>
<passThrough>true or false</passThrough>
<fakeDomainCheck>true or false</fakeDomainCheck>
<debug>true or false</debug>
</mailet>

forwardto can be used instead of forwardTo; such name is kept for backward compatibility.

version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $

Fields Summary
Constructors Summary
Methods Summary
protected booleanattachError()

return
false

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

        String[] allowedArray = {
//            "static",
            "debug",
            "passThrough",
            "fakeDomainCheck",
            "forwardto",
            "forwardTo"
        };
        return allowedArray;
    
protected intgetAttachmentType()

return
NONE

        return NONE;
    
protected intgetInLineType()

return
UNALTERED

        return UNALTERED;
    
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "Forward Mailet";
    
protected java.lang.StringgetMessage()

return
""

        return "";
    
protected java.util.CollectiongetRecipients()

return
the recipients init parameter or null if missing

        Collection newRecipients = new HashSet();
        String addressList = getInitParameter("forwardto",getInitParameter("forwardTo"));
        
        // if nothing was specified, throw an exception
        if (addressList == null) {
            throw new MessagingException("Failed to initialize \"recipients\" list: no <forwardTo> or <forwardto> init parameter found");
        }

        try {
            InternetAddress[] iaarray = InternetAddress.parse(addressList, false);
            for (int i = 0; i < iaarray.length; i++) {
                String addressString = iaarray[i].getAddress();
                MailAddress specialAddress = getSpecialAddress(addressString,
                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});
                if (specialAddress != null) {
                    newRecipients.add(specialAddress);
                } else {
                    newRecipients.add(new MailAddress(iaarray[i]));
                }
            }
        } catch (Exception e) {
            throw new MessagingException("Exception thrown in getRecipients() parsing: " + addressList, e);
        }
        if (newRecipients.size() == 0) {
            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
        }

        return newRecipients;
    
protected org.apache.mailet.MailAddressgetReplyTo()

return
null

        return null;
    
protected org.apache.mailet.MailAddressgetReversePath()

return
null

        return null;
    
protected org.apache.mailet.MailAddressgetSender()

return
null

        return null;
    
protected java.lang.StringgetSubject()

return
null

        return null;
    
protected java.lang.StringgetSubjectPrefix()

return
""

        return null;
    
protected javax.mail.internet.InternetAddress[]getTo()

return
null

        return null;
    
protected booleanisReply()

return
false

        return false;