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

Bounce

public class Bounce extends AbstractNotify

Generates a response to the reverse-path address. Note that this is different than a mail-client's reply, which would use the Reply-To or From header.

Bounced messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".
The reverse-path and the Return-Path header of the response is set to "null" ("<>"), meaning that no reply should be sent.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.
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.

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="Bounce">
<sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
<attachError>true or false, default=false</attachError>
<message>notice attached to the original message text (optional)</message>
<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>
<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 or false</passThrough>
<fakeDomainCheck>true or false</fakeDomainCheck>
<recipients>sender</recipients>
<reversePath>null</reversePath>
<inline>see {@link Resend}</inline>
<attachment>see {@link Resend}</attachment>
<isReply>true</isReply>
<debug>true or false</debug>
</mailet>

notice and sendingAddress can be used instead of message and sender; such names are kept for backward compatibility.

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

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.String[]getAllowedInitParameters()
Gets the expected init parameters.

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

return
a string describing this mailet

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

return
SpecialAddress.REVERSE_PATH

        Collection newRecipients = new HashSet();
        newRecipients.add(SpecialAddress.REVERSE_PATH);
        return newRecipients;
    
protected org.apache.mailet.MailAddressgetReversePath(org.apache.mailet.Mail originalMail)

return
SpecialAddress.NULL (the meaning of bounce)

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

return
SpecialAddress.REVERSE_PATH

        InternetAddress[] apparentlyTo = new InternetAddress[1];
        apparentlyTo[0] = SpecialAddress.REVERSE_PATH.toInternetAddress();
        return apparentlyTo;
    
public voidservice(org.apache.mailet.Mail originalMail)
Service does the hard work,and redirects the originalMail in the form specified. Checks that the original return path is not empty, and then calls super.service(originalMail), otherwise just returns.

param
originalMail the mail to process and redirect
throws
MessagingException if a problem arises formulating the redirected mail

        if (originalMail.getSender() == null) {
            if (isDebug)
                log("Processing a bounce request for a message with an empty reverse-path.  No bounce will be sent.");
            if(!getPassThrough(originalMail)) {
                originalMail.setState(Mail.GHOST);
            }
            return;
        }

        if (isDebug)
            log("Processing a bounce request for a message with a reverse path.  The bounce will be sent to " + originalMail.getSender().toString());

        super.service(originalMail);