|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.mailet.GenericMailet | +--org.apache.james.transport.mailets.Redirect
A mailet providing configurable redirection services
This mailet can produce listserver, forward and notify behaviour, with the original
message intact, attached, appended or left out altogether.
This built in functionality is controlled by the configuration as laid out below.
However it is also designed to be easily subclassed to make authoring redirection
mailets simple.
By extending it and overriding one or more of these methods new behaviour can
be quickly created without the author having to address any other issue than
the relevant one:
The configuration parameters are:
<recipients> | A comma delimited list of email addresses for recipients of this message, it will use the "to" list if not specified. These addresses will only appear in the To: header if no "to" list is supplied. |
<to> | A comma delimited list of addresses to appear in the To: header,
the email will only be delivered to these addresses if they are in the recipients
list. The recipients list will be used if this is not supplied. |
<sender> | A single email address to appear in the From: header It can include constants "sender" and "postmaster" |
<message> | A text message to be the body of the email. Can be omitted. |
<inline> |
One of the following items:
|
<attachment> |
One of the following items:
|
<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. |
<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) |
<replyto> | A single email address to appear in the Rely-To: header, can also be "sender" or "postmaster", this header is not set if this is omited. |
<prefix> | An optional subject prefix prepended to the original message
subject, for example: Undeliverable mail: |
<static> |
TRUE or FALSE, if this is true it hints to the mailet that none of the
parameters are set dynamically, and therefore they can be set once in
the init method. This defaults to false. |
Example:
<mailet match="RecipientIs=test@localhost" class="Redirect">
<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="Redirect">
<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>
<static>TRUE</static>
</mailet>
Constructor Summary | |
Redirect()
|
Method Summary | |
boolean |
attachError()
return true to append a description of any error to the main body part if getInlineType does not return "UNALTERED" |
int |
getAttachmentType()
returns one of these values to indicate how to attach the original message BODY : original message body is attached as plain text to the new message HEADS : original message headers are attached as plain text to the new message ALL : original is attached as plain text with all headers MESSAGE : original message is attached as type message/rfc822, a complete mail message. |
int |
getInLineType()
returns one of these values to indicate how to append the original message UNALTERED : original message is the new message body BODY : original message body is appended to the new message HEADS : original message headers are appended to the new message ALL : original is appended with all headers NONE : original is not appended |
String |
getMailetInfo()
Return a string describing this mailet. |
String |
getMessage()
must return either an empty string, or a message to which the redirect can be attached/appended |
boolean |
getPassThrough()
return true to allow thie original message to continue through the processor, false to GHOST it |
Collection |
getRecipients()
must return a Collection of recipient MailAddresses |
MailAddress |
getReplyTo()
Returns the reply to address as a string. |
MailAddress |
getSender()
returns the senders address, as a MailAddress |
String |
getSubjectPrefix()
return a prefix for the message subject |
InternetAddress[] |
getTo()
returns an array of InternetAddress 'es for the To: header |
void |
init()
init will setup static values for sender, recipients, message text, and reply to if isStatic() returns true it calls getSender(), getReplyTo(), getMessage(), and getRecipients() and getTo() |
boolean |
isStatic()
return true to reduce calls to getTo, getSender, getRecipients, getReplyTo amd getMessage where these values don't change (eg hard coded, or got at startup from the mailet config) return false where any of these methods generate their results dynamically eg in response to the message being processed, or by refrence to a repository of users |
void |
service(Mail mail)
Service does the hard work,and redirects the mail in the form specified |
Methods inherited from class org.apache.mailet.GenericMailet |
destroy, 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 |
public Redirect()
Method Detail |
public int getAttachmentType()
public int getInLineType()
public String getMailetInfo()
getMailetInfo
in interface Mailet
getMailetInfo
in class GenericMailet
public String getMessage()
public boolean getPassThrough()
public Collection getRecipients()
public MailAddress getReplyTo()
public MailAddress getSender()
public boolean isStatic()
public String getSubjectPrefix()
public InternetAddress[] getTo()
public boolean attachError()
public void init() throws MessagingException
init
in class GenericMailet
MessagingException
- if an exception occurs that interrupts the mailet's normal operationpublic void service(Mail mail) throws MessagingException
service
in interface Mailet
service
in class GenericMailet
mail
- the mail to process and redirect
MessagingException
- if a problem arising formulating the redirected mail
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |