FileDocCategorySizeDatePackage
NotifySender.javaAPI DocApache James 2.3.17288Fri Jan 12 12:56:30 GMT 2007org.apache.james.transport.mailets

NotifySender

public class NotifySender extends AbstractNotify

Sends a notification message to the sender of a message.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.
The "To:" header of the notification message can be set to "unaltered"; if missing will be set to the sender of the notified message.
A notice text can be specified, and in such case will be inserted into the notification inline text.
If the notified message has an "error message" set, it will be inserted into the notification inline text. If the attachStackTrace init parameter is set to true, such error message will be attached to the notification message.
The notified messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="NotifySender">
<sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
<attachError>true or false, default=false</attachError>
<prefix>optional subject prefix prepended to the original message</prefix>
<inline>see {@link Resend}, default=none</inline>
<attachment>see {@link Resend}, default=message</attachment>
<passThrough>true or false, default=true</passThrough>
<fakeDomainCheck>true or false, default=true</fakeDomainCheck>
<to>unaltered or sender or from(optional, defaults to sender)</to>
<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">
<sender>an address or postmaster or sender or unaltered</sender>
<attachError>true or false</attachError>
<message>dynamically built</message>
<prefix>a string</prefix>
<passThrough>true</passThrough>
<fakeDomainCheck>true or false</fakeDomainCheck>
<to>unaltered or sender or from<;/to>
<recipients>sender</recipients>
<inline>none</inline>
<attachment>message</attachment>
<isReply>true</isReply>
<debug>true or false</debug>
</mailet>

notice, sendingAddress and attachStackTrace can be used instead of message, sender and attachError; such names are 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
the attachStackTrace init parameter, or the attachError init parameter if missing, or false if missing

        String parameter = getInitParameter("attachStackTrace");
        if (parameter == null) {
            return super.attachError();
        }        
        return new Boolean(parameter).booleanValue();
    
protected java.lang.String[]getAllowedInitParameters()
Gets the expected init parameters.

        String[] allowedArray = {
//            "static",
            "debug",
            "passThrough",
            "fakeDomainCheck",
            "inline",
            "attachment",
            "message",
            "notice",
            "sender",
            "sendingAddress",
            "prefix",
            "attachError",
            "attachStackTrace",
            "to"
        };
        return allowedArray;
    
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

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

return
SpecialAddress.SENDER, indicating the sender of the current mail

        Collection newRecipients = new HashSet();
        newRecipients.add(SpecialAddress.SENDER);
        return newRecipients;
    
protected javax.mail.internet.InternetAddress[]getTo()

return
SpecialAddress.UNALTERED if specified or SpecialAddress.SENDER if missing

        String addressList = getInitParameter("to");
        InternetAddress[] iaarray = new InternetAddress[1];
        iaarray[0] = SpecialAddress.SENDER.toInternetAddress();
        if (addressList != null) {
            MailAddress specialAddress = getSpecialAddress(addressList,
                                            new String[] {"sender", "unaltered", "from"});
            if (specialAddress != null) {
                iaarray[0] = specialAddress.toInternetAddress();
            } else {
                log("\"to\" parameter ignored, set to sender");
            }
        }
        return iaarray;