org.apache.james.transport.mailets
Class Bounce

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.AbstractRedirect
          extended by org.apache.james.transport.mailets.AbstractNotify
              extended by org.apache.james.transport.mailets.Bounce
All Implemented Interfaces:
Mailet, MailetConfig

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 Resend, default=none</inline>
   <attachment>see 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 Resend</inline>
   <attachment>see 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.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.james.transport.mailets.AbstractRedirect
AbstractRedirect.SpecialAddress
 
Field Summary
 
Fields inherited from class org.apache.james.transport.mailets.AbstractRedirect
ALL, BODY, HEADS, isDebug, isStatic, MESSAGE, NONE, UNALTERED
 
Constructor Summary
Bounce()
           
 
Method Summary
protected  java.lang.String[] getAllowedInitParameters()
          Gets the expected init parameters.
 java.lang.String getMailetInfo()
          Return a string describing this mailet.
protected  java.util.Collection getRecipients()
          Gets the recipients property.
protected  MailAddress getReversePath(Mail originalMail)
          Gets the reversePath property, built dynamically using the original Mail object.
protected  javax.mail.internet.InternetAddress[] getTo()
          Gets the to property.
 void service(Mail originalMail)
          Service does the hard work,and redirects the originalMail in the form specified.
 
Methods inherited from class org.apache.james.transport.mailets.AbstractNotify
getAttachmentType, getInLineType, getMessage, getMessage, getPassThrough, getReplyTo, getSender, getSubject, getSubjectPrefix, isReply, setSubjectPrefix
 
Methods inherited from class org.apache.james.transport.mailets.AbstractRedirect
attachError, attachError, buildAlteredMessage, changeSubject, getAttachmentType, getFakeDomainCheck, getFakeDomainCheck, getInLineType, getMessageHeaders, getPassThrough, getRecipients, getReplyTo, getReversePath, getSender, getSpecialAddress, getSubject, getSubjectPrefix, getTo, getTypeCode, init, isReply, isStatic, replaceInternetAddresses, replaceMailAddresses, senderDomainIsValid, setIsReply, setRecipients, setReplyTo, setReversePath, setSender, setTo
 
Methods inherited from class org.apache.mailet.GenericMailet
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bounce

public Bounce()
Method Detail

getMailetInfo

public java.lang.String getMailetInfo()
Return a string describing this mailet.

Specified by:
getMailetInfo in interface Mailet
Overrides:
getMailetInfo in class GenericMailet
Returns:
a string describing this mailet

getAllowedInitParameters

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

Overrides:
getAllowedInitParameters in class AbstractRedirect
Returns:
null meaning no check

getRecipients

protected java.util.Collection getRecipients()
Description copied from class: AbstractRedirect
Gets the recipients property. Returns the collection of recipients of the new message, or null if no change is requested. Is a "getX()" method.

Specified by:
getRecipients in class AbstractNotify
Returns:
SpecialAddress.REVERSE_PATH

getTo

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

Overrides:
getTo in class AbstractNotify
Returns:
SpecialAddress.REVERSE_PATH

getReversePath

protected MailAddress getReversePath(Mail originalMail)
Description copied from class: AbstractRedirect
Gets the reversePath property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Overrides:
getReversePath in class AbstractNotify
Returns:
SpecialAddress.NULL (the meaning of bounce)

service

public void service(Mail originalMail)
             throws javax.mail.MessagingException
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.

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


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