org.apache.james.transport.mailets
Class DSNBounce

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.DSNBounce
All Implemented Interfaces:
Mailet, MailetConfig

public class DSNBounce
extends AbstractNotify

Generates a Delivery Status Notification (DSN) 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.

Supports the passThrough init parameter (true if missing).

Sample configuration:


 <mailet match="All" class="DSNBounce">
   <sender>an address or postmaster or sender or unaltered, 
 default=postmaster</sender>
   <prefix>optional subject prefix prepended to the original 
 message</prefix>
   <attachment>message, heads or none, default=message</attachment>
   <messageString>the message sent in the bounce, the first occurrence of the pattern [machine] is replaced with the name of the executing machine, default=Hi. This is the James mail server at [machine] ... </messageString>
   <passThrough>true or false, default=true</passThrough>
   <debug>true or false, default=false</debug>
 </mailet>
 

See Also:
AbstractNotify

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
DSNBounce()
           
 
Method Summary
protected  javax.mail.internet.MimeBodyPart createAttachedOriginal(Mail originalMail, int attachmentType)
          Create a MimeBodyPart with the original Mail as Attachment
protected  javax.mail.internet.MimeBodyPart createDSN(Mail originalMail)
          creates the DSN-bodypart for automated processing
protected  javax.mail.internet.MimeBodyPart createTextMsg(Mail originalMail)
          Create a MimeBodyPart with a textual description for human readers.
protected  java.lang.String[] getAllowedInitParameters()
          Gets the expected init parameters.
protected  int getAttachmentType()
          Gets the attachment property.
protected  java.lang.String getErrorMsg(javax.mail.MessagingException me)
          Utility method for getting the error message from the (nested) exception.
 java.lang.String getMailetInfo()
          Returns information about the mailet, such as author, version, and copyright.
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  java.lang.String getStatus(javax.mail.MessagingException me)
          Guessing status code by the exception provided.
protected  javax.mail.internet.InternetAddress[] getTo()
          Gets the to property.
 void init()
          Initialize the mailet
protected  java.lang.String newName(Mail mail)
          Create a unique new primary key name.
 void service(Mail originalMail)
          Service does the hard work and bounces the originalMail in the format specified by RFC3464.
 
Methods inherited from class org.apache.james.transport.mailets.AbstractNotify
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, 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

DSNBounce

public DSNBounce()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Initialize the mailet

Overrides:
init in class AbstractRedirect
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 bounces the originalMail in the format specified by RFC3464.

Specified by:
service in interface Mailet
Overrides:
service in class AbstractRedirect
Parameters:
originalMail - the mail to bounce
Throws:
javax.mail.MessagingException - if a problem arises formulating the redirected mail
See Also:
Mailet.service(org.apache.mailet.Mail)

createTextMsg

protected javax.mail.internet.MimeBodyPart createTextMsg(Mail originalMail)
                                                  throws javax.mail.MessagingException
Create a MimeBodyPart with a textual description for human readers.

Parameters:
originalMail -
Returns:
MimeBodyPart
Throws:
javax.mail.MessagingException

createDSN

protected javax.mail.internet.MimeBodyPart createDSN(Mail originalMail)
                                              throws javax.mail.MessagingException
creates the DSN-bodypart for automated processing

Parameters:
originalMail -
Returns:
MimeBodyPart dsn-bodypart
Throws:
javax.mail.MessagingException

createAttachedOriginal

protected javax.mail.internet.MimeBodyPart createAttachedOriginal(Mail originalMail,
                                                                  int attachmentType)
                                                           throws javax.mail.MessagingException
Create a MimeBodyPart with the original Mail as Attachment

Parameters:
originalMail -
Returns:
MimeBodyPart
Throws:
javax.mail.MessagingException

getStatus

protected java.lang.String getStatus(javax.mail.MessagingException me)
Guessing status code by the exception provided. This method should use the status attribute when the SMTP-handler somewhen provides it

Parameters:
MessagingException -
Returns:
status code

getErrorMsg

protected java.lang.String getErrorMsg(javax.mail.MessagingException me)
Utility method for getting the error message from the (nested) exception.

Parameters:
MessagingException -
Returns:
error message

newName

protected java.lang.String newName(Mail mail)
                            throws javax.mail.MessagingException
Create a unique new primary key name.

Parameters:
mail - the mail to use as the basis for the new mail name
Returns:
a new name
Throws:
javax.mail.MessagingException

getMailetInfo

public java.lang.String getMailetInfo()
Description copied from class: GenericMailet
Returns information about the mailet, such as author, version, and copyright. By default, this method returns an empty string. Override this method to have it return a meaningful value.

Specified by:
getMailetInfo in interface Mailet
Overrides:
getMailetInfo in class GenericMailet
Returns:
information about this mailet, by default an empty string

getAllowedInitParameters

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

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

getAttachmentType

protected int getAttachmentType()
                         throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
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.

Overrides:
getAttachmentType in class AbstractNotify
Returns:
the attachment init parameter, or MESSAGE if missing
Throws:
javax.mail.MessagingException

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)


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