001: /****************************************************************
002: * Licensed to the Apache Software Foundation (ASF) under one *
003: * or more contributor license agreements. See the NOTICE file *
004: * distributed with this work for additional information *
005: * regarding copyright ownership. The ASF licenses this file *
006: * to you under the Apache License, Version 2.0 (the *
007: * "License"); you may not use this file except in compliance *
008: * with the License. You may obtain a copy of the License at *
009: * *
010: * http://www.apache.org/licenses/LICENSE-2.0 *
011: * *
012: * Unless required by applicable law or agreed to in writing, *
013: * software distributed under the License is distributed on an *
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015: * KIND, either express or implied. See the License for the *
016: * specific language governing permissions and limitations *
017: * under the License. *
018: ****************************************************************/package org.apache.james.transport.mailets;
019:
020: /**
021: * <P>A mailet providing configurable redirection services.</P>
022: * <P>Can produce listserver, forward and notify behaviour, with the original
023: * message intact, attached, appended or left out altogether.
024: * Can be used as a replacement to {@link Redirect}, having more consistent defaults,
025: * and new options available.<BR>
026: * Use <CODE>Resend</CODE> if you need full control, <CODE>Redirect</CODE> if
027: * the more automatic behaviour of some parameters is appropriate.</P>
028: * <P>This built in functionality is controlled by the configuration as laid out below.
029: * In the table please note that the parameters controlling message headers
030: * accept the <B>"unaltered"</B> value, whose meaning is to keep the associated
031: * header unchanged and, unless stated differently, corresponds to the assumed default
032: * if the parameter is missing.</P>
033: * <P>The configuration parameters are:</P>
034: * <TABLE width="75%" border="1" cellspacing="2" cellpadding="2">
035: * <TR valign=top>
036: * <TD width="20%"><recipients></TD>
037: * <TD width="80%">
038: * A comma delimited list of addresses for recipients of this message.<BR>
039: * Such addresses can contain "full names", like
040: * <I>Mr. John D. Smith <john.smith@xyz.com></I>.<BR>
041: * The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered";
042: * "replyTo" uses the ReplyTo header if available, otherwise the
043: * From header if available, otherwise the Sender header if available, otherwise the return-path;
044: * "from" is made equivalent to "sender", and "to" is made equivalent to "recipients";
045: * "null" is ignored.
046: * Default: "unaltered".
047: * </TD>
048: * </TR>
049: * <TR valign=top>
050: * <TD width="20%"><to></TD>
051: * <TD width="80%">
052: * A comma delimited list of addresses to appear in the To: header.<BR>
053: * Such addresses can contain "full names", like
054: * <I>Mr. John D. Smith <john.smith@xyz.com></I>.<BR>
055: * The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered";
056: * "from" uses the From header if available, otherwise the Sender header if available,
057: * otherwise the return-path;
058: * "replyTo" uses the ReplyTo header if available, otherwise the
059: * From header if available, otherwise the Sender header if available, otherwise the return-path;
060: * "recipients" is made equivalent to "to";
061: * if "null" is specified alone it will remove this header.
062: * Default: "unaltered".
063: * </TD>
064: * </TR>
065: * <TR valign=top>
066: * <TD width="20%"><sender></TD>
067: * <TD width="80%">
068: * A single email address to appear in the From: header and become the sender.<BR>
069: * It can include constants "sender", "postmaster" and "unaltered";
070: * "sender" is equivalent to "unaltered".<BR>
071: * Default: "unaltered".
072: * </TD>
073: * </TR>
074: * <TR valign=top>
075: * <TD width="20%"><message></TD>
076: * <TD width="80%">
077: * A text message to insert into the body of the email.<BR>
078: * Default: no message is inserted.
079: * </TD>
080: * </TR>
081: * <TR valign=top>
082: * <TD width="20%"><inline></TD>
083: * <TD width="80%">
084: * <P>One of the following items:</P>
085: * <UL>
086: * <LI>unaltered The original message is the new
087: * message, for forwarding/aliasing</LI>
088: * <LI>heads The
089: * headers of the original message are appended to the message</LI>
090: * <LI>body The
091: * body of the original is appended to the new message</LI>
092: * <LI>all Both
093: * headers and body are appended</LI>
094: * <LI>none Neither
095: * body nor headers are appended</LI>
096: * </UL>
097: * Default: "unaltered".
098: * </TD>
099: * </TR>
100: * <TR valign=top>
101: * <TD width="20%"><attachment></TD>
102: * <TD width="80%">
103: * <P>One of the following items:</P>
104: * <UL>
105: * <LI>heads The headers of the original
106: * are attached as text</LI>
107: * <LI>body The body of the original
108: * is attached as text</LI>
109: * <LI>all Both
110: * headers and body are attached as a single text file</LI>
111: * <LI>none Nothing is attached</LI>
112: * <LI>message The original message is attached as type message/rfc822,
113: * this means that it can, in many cases, be opened, resent, fw'd, replied
114: * to etc by email client software.</LI>
115: * </UL>
116: * Default: "none".
117: * </TD>
118: * </TR>
119: * <TR valign=top>
120: * <TD width="20%"><passThrough></TD>
121: * <TD width="80%">
122: * true or false, if true the original message continues in the
123: * mailet processor after this mailet is finished. False causes the original
124: * to be stopped.<BR>
125: * Default: false.
126: * </TD>
127: * </TR>
128: * <TR valign=top>
129: * <TD width="20%"><fakeDomainCheck></TD>
130: * <TD width="80%">
131: * true or false, if true will check if the sender domain is valid.<BR>
132: * Default: true.
133: * </TD>
134: * </TR>
135: * <TR valign=top>
136: * <TD width="20%"><attachError></TD>
137: * <TD width="80%">
138: * true or false, if true any error message available to the
139: * mailet is appended to the message body (except in the case of inline ==
140: * unaltered).<BR>
141: * Default: false.
142: * </TD>
143: * </TR>
144: * <TR valign=top>
145: * <TD width="20%"><replyTo></TD>
146: * <TD width="80%">
147: * A single email address to appear in the Reply-To: header.<BR>
148: * It can include constants "sender", "postmaster" "null" and "unaltered";
149: * if "null" is specified it will remove this header.<BR>
150: * Default: "unaltered".
151: * </TD>
152: * </TR>
153: * <TR valign=top>
154: * <TD width="20%"><reversePath></TD>
155: * <TD width="80%">
156: * A single email address to appear in the Return-Path: header.<BR>
157: * It can include constants "sender", "postmaster" "null" and "unaltered";
158: * if "null" is specified then it will set it to <>, meaning "null return path".<BR>
159: * Default: "unaltered".
160: * </TD>
161: * </TR>
162: * <TR valign=top>
163: * <TD width="20%"><subject></TD>
164: * <TD width="80%">
165: * An optional string to use as the subject.<BR>
166: * Default: keep the original message subject.
167: * </TD>
168: * </TR>
169: * <TR valign=top>
170: * <TD width="20%"><prefix></TD>
171: * <TD width="80%">
172: * An optional subject prefix prepended to the original message
173: * subject, or to a new subject specified with the <I><subject></I> parameter.<BR>
174: * For example: <I>[Undeliverable mail]</I>.<BR>
175: * Default: "".
176: * </TD>
177: * </TR>
178: * <TR valign=top>
179: * <TD width="20%"><isReply></TD>
180: * <TD width="80%">
181: * true or false, if true the IN_REPLY_TO header will be set to the
182: * id of the current message.<BR>
183: * Default: false.
184: * </TD>
185: * </TR>
186: * <TR valign=top>
187: * <TD width="20%"><debug></TD>
188: * <TD width="80%">
189: * true or false. If this is true it tells the mailet to write some debugging
190: * information to the mailet log.<BR>
191: * Default: false.
192: * </TD>
193: * </TR>
194: * </TABLE>
195: *
196: * <P>Example:</P>
197: * <PRE><CODE>
198: * <mailet match="RecipientIs=test@localhost" class="Resend">
199: * <recipients>x@localhost, y@localhost, z@localhost</recipients>
200: * <to>list@localhost</to>
201: * <sender>owner@localhost</sender>
202: * <message>sent on from James</message>
203: * <inline>unaltered</inline>
204: * <passThrough>FALSE</passThrough>
205: * <replyTo>postmaster</replyTo>
206: * <prefix xml:space="preserve">[test mailing] </prefix>
207: * <!-- note the xml:space="preserve" to preserve whitespace -->
208: * <static>TRUE</static>
209: * </mailet>
210: * </CODE></PRE>
211: *
212: * <P>and:</P>
213: *
214: * <PRE><CODE>
215: * <mailet match="All" class="Resend">
216: * <recipients>x@localhost</recipients>
217: * <sender>postmaster</sender>
218: * <message xml:space="preserve">Message marked as spam:</message>
219: * <inline>heads</inline>
220: * <attachment>message</attachment>
221: * <passThrough>FALSE</passThrough>
222: * <attachError>TRUE</attachError>
223: * <replyTo>postmaster</replyTo>
224: * <prefix>[spam notification]</prefix>
225: * </mailet>
226: * </CODE></PRE>
227: *
228: * <P>The following example forwards the message without any modification, based on the defaults:</P>
229: * <PRE><CODE>
230: * <mailet match="All" class="Resend"/;>
231: * </CODE></PRE>
232: * <P><I>replyto</I> can be used instead of
233: * <I>replyTo</I>; such name is kept for backward compatibility.</P>
234: * <P><B>WARNING: as the message (or a copy of it) is reinjected in the spool without any modification,
235: * the preceding example is very likely to cause a "configuration loop" in your system,
236: * unless some other mailet has previously modified something (a header for instance) that could force the resent
237: * message follow a different path so that it does not return here unchanged.</B></P>
238: *
239: * @version CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $
240: * @since 2.2.0
241: */
242:
243: public class Resend extends AbstractRedirect {
244:
245: /**
246: * Returns a string describing this mailet.
247: *
248: * @return a string describing this mailet
249: */
250: public String getMailetInfo() {
251: return "Redirect Mailet";
252: }
253:
254: /** Gets the expected init parameters. */
255: protected String[] getAllowedInitParameters() {
256: String[] allowedArray = {
257: // "static",
258: "debug", "passThrough", "fakeDomainCheck", "inline",
259: "attachment", "message", "recipients", "to", "replyTo",
260: "replyto", "reversePath", "sender", "subject",
261: "prefix", "attachError", "isReply" };
262: return allowedArray;
263: }
264:
265: /* ******************************************************************** */
266: /* ****************** Begin of getX and setX methods ****************** */
267: /* ******************************************************************** */
268:
269: /* ******************************************************************** */
270: /* ******************* End of getX and setX methods ******************* */
271: /* ******************************************************************** */
272:
273: }
|