org.apache.james.transport.mailets
Class Resend

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

public class Resend
extends AbstractRedirect

A mailet providing configurable redirection services.

Can produce listserver, forward and notify behaviour, with the original message intact, attached, appended or left out altogether. Can be used as a replacement to Redirect, having more consistent defaults, and new options available.
Use Resend if you need full control, Redirect if the more automatic behaviour of some parameters is appropriate.

This built in functionality is controlled by the configuration as laid out below. In the table please note that the parameters controlling message headers accept the "unaltered" value, whose meaning is to keep the associated header unchanged and, unless stated differently, corresponds to the assumed default if the parameter is missing.

The configuration parameters are:

<recipients> A comma delimited list of addresses for recipients of this message.
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "from" is made equivalent to "sender", and "to" is made equivalent to "recipients"; "null" is ignored. Default: "unaltered".
<to> A comma delimited list of addresses to appear in the To: header.
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "from" uses the From header if available, otherwise the Sender header if available, otherwise the return-path; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "recipients" is made equivalent to "to"; if "null" is specified alone it will remove this header. Default: "unaltered".
<sender> A single email address to appear in the From: header and become the sender.
It can include constants "sender", "postmaster" and "unaltered"; "sender" is equivalent to "unaltered".
Default: "unaltered".
<message> A text message to insert into the body of the email.
Default: no message is inserted.
<inline>

One of the following items:

  • unaltered     The original message is the new message, for forwarding/aliasing
  • heads          The headers of the original message are appended to the message
  • body           The body of the original is appended to the new message
  • all               Both headers and body are appended
  • none           Neither body nor headers are appended
Default: "unaltered".
<attachment>

One of the following items:

  • heads      The headers of the original are attached as text
  • body       The body of the original is attached as text
  • all           Both headers and body are attached as a single text file
  • none       Nothing is attached
  • message  The original message is attached as type message/rfc822, this means that it can, in many cases, be opened, resent, fw'd, replied to etc by email client software.
Default: "none".
<passThrough> true or false, if true the original message continues in the mailet processor after this mailet is finished. False causes the original to be stopped.
Default: false.
<fakeDomainCheck> true or false, if true will check if the sender domain is valid.
Default: true.
<attachError> true or false, if true any error message available to the mailet is appended to the message body (except in the case of inline == unaltered).
Default: false.
<replyTo> A single email address to appear in the Reply-To: header.
It can include constants "sender", "postmaster" "null" and "unaltered"; if "null" is specified it will remove this header.
Default: "unaltered".
<reversePath> A single email address to appear in the Return-Path: header.
It can include constants "sender", "postmaster" "null" and "unaltered"; if "null" is specified then it will set it to <>, meaning "null return path".
Default: "unaltered".
<subject> An optional string to use as the subject.
Default: keep the original message subject.
<prefix> An optional subject prefix prepended to the original message subject, or to a new subject specified with the <subject> parameter.
For example: [Undeliverable mail].
Default: "".
<isReply> true or false, if true the IN_REPLY_TO header will be set to the id of the current message.
Default: false.
<debug> true or false. If this is true it tells the mailet to write some debugging information to the mailet log.
Default: false.

Example:


  <mailet match="RecipientIs=test@localhost" class="Resend">
    <recipients>x@localhost, y@localhost, z@localhost</recipients>
    <to>list@localhost</to>
    <sender>owner@localhost</sender>
    <message>sent on from James</message>
    <inline>unaltered</inline>
    <passThrough>FALSE</passThrough>
    <replyTo>postmaster</replyTo>
    <prefix xml:space="preserve">[test mailing] </prefix>
    <!-- note the xml:space="preserve" to preserve whitespace -->
    <static>TRUE</static>
 </mailet>
 

and:


  <mailet match="All" class="Resend">
    <recipients>x@localhost</recipients>
    <sender>postmaster</sender>
    <message xml:space="preserve">Message marked as spam:</message>
    <inline>heads</inline>
    <attachment>message</attachment>
    <passThrough>FALSE</passThrough>
    <attachError>TRUE</attachError>
    <replyTo>postmaster</replyTo>
    <prefix>[spam notification]</prefix>
  </mailet>
 

The following example forwards the message without any modification, based on the defaults:


  <mailet match="All" class="Resend"/;>
 

replyto can be used instead of replyTo; such name is kept for backward compatibility.

WARNING: as the message (or a copy of it) is reinjected in the spool without any modification, the preceding example is very likely to cause a "configuration loop" in your system, unless some other mailet has previously modified something (a header for instance) that could force the resent message follow a different path so that it does not return here unchanged.

Since:
2.2.0
Version:
CVS $Revision: 382444 $ $Date: 2006-03-02 16:56:32 +0000 (gio, 02 mar 2006) $

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
Resend()
           
 
Method Summary
protected  java.lang.String[] getAllowedInitParameters()
          Gets the expected init parameters.
 java.lang.String getMailetInfo()
          Returns a string describing this mailet.
 
Methods inherited from class org.apache.james.transport.mailets.AbstractRedirect
attachError, attachError, buildAlteredMessage, changeSubject, getAttachmentType, getAttachmentType, getFakeDomainCheck, getFakeDomainCheck, getInLineType, getInLineType, getMessage, getMessage, getMessageHeaders, getPassThrough, getPassThrough, getRecipients, getRecipients, getReplyTo, getReplyTo, getReversePath, getReversePath, getSender, getSender, getSpecialAddress, getSubject, getSubject, getSubjectPrefix, getSubjectPrefix, getTo, getTo, getTypeCode, init, isReply, isReply, isStatic, replaceInternetAddresses, replaceMailAddresses, senderDomainIsValid, service, setIsReply, setRecipients, setReplyTo, setReversePath, setSender, setSubjectPrefix, 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

Resend

public Resend()
Method Detail

getMailetInfo

public java.lang.String getMailetInfo()
Returns 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


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