View Javadoc

1   /*****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.james.transport.mailets;
21  
22  /***
23   * <P>A mailet providing configurable redirection services.</P>
24   * <P>Can produce listserver, forward and notify behaviour, with the original
25   * message intact, attached, appended or left out altogether.
26   * Can be used as a replacement to {@link Redirect}, having more consistent defaults,
27   * and new options available.<BR>
28   * Use <CODE>Resend</CODE> if you need full control, <CODE>Redirect</CODE> if
29   * the more automatic behaviour of some parameters is appropriate.</P>
30   * <P>This built in functionality is controlled by the configuration as laid out below.
31   * In the table please note that the parameters controlling message headers
32   * accept the <B>&quot;unaltered&quot;</B> value, whose meaning is to keep the associated
33   * header unchanged and, unless stated differently, corresponds to the assumed default
34   * if the parameter is missing.</P>
35   * <P>The configuration parameters are:</P>
36   * <TABLE width="75%" border="1" cellspacing="2" cellpadding="2">
37   * <TR valign=top>
38   * <TD width="20%">&lt;recipients&gt;</TD>
39   * <TD width="80%">
40   * A comma delimited list of addresses for recipients of this message.<BR>
41   * Such addresses can contain &quot;full names&quot;, like
42   * <I>Mr. John D. Smith &lt;john.smith@xyz.com&gt;</I>.<BR>
43   * The list can include constants &quot;sender&quot;, &quot;from&quot;, &quot;replyTo&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;recipients&quot;, &quot;to&quot;, &quot;null&quot; and &quot;unaltered&quot;;
44   * &quot;replyTo&quot; uses the ReplyTo header if available, otherwise the
45   * From header if available, otherwise the Sender header if available, otherwise the return-path;
46   * &quot;from&quot; is made equivalent to &quot;sender&quot;, and &quot;to&quot; is made equivalent to &quot;recipients&quot;;
47   * &quot;null&quot; is ignored.
48   * Default: &quot;unaltered&quot;.
49   * </TD>
50   * </TR>
51   * <TR valign=top>
52   * <TD width="20%">&lt;to&gt;</TD>
53   * <TD width="80%">
54   * A comma delimited list of addresses to appear in the To: header.<BR>
55   * Such addresses can contain &quot;full names&quot;, like
56   * <I>Mr. John D. Smith &lt;john.smith@xyz.com&gt;</I>.<BR>
57   * The list can include constants &quot;sender&quot;, &quot;from&quot;, &quot;replyTo&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;recipients&quot;, &quot;to&quot;, &quot;null&quot; and &quot;unaltered&quot;;
58   * &quot;from&quot; uses the From header if available, otherwise the Sender header if available,
59   * otherwise the return-path;
60   * &quot;replyTo&quot; uses the ReplyTo header if available, otherwise the
61   * From header if available, otherwise the Sender header if available, otherwise the return-path;
62   * &quot;recipients&quot; is made equivalent to &quot;to&quot;;
63   * if &quot;null&quot; is specified alone it will remove this header.
64   * Default: &quot;unaltered&quot;.
65   * </TD>
66   * </TR>
67   * <TR valign=top>
68   * <TD width="20%">&lt;sender&gt;</TD>
69   * <TD width="80%">
70   * A single email address to appear in the From: header and become the sender.<BR>
71   * It can include constants &quot;sender&quot;, &quot;postmaster&quot; and &quot;unaltered&quot;;
72   * &quot;sender&quot; is equivalent to &quot;unaltered&quot;.<BR>
73   * Default: &quot;unaltered&quot;.
74   * </TD>
75   * </TR>
76   * <TR valign=top>
77   * <TD width="20%">&lt;message&gt;</TD>
78   * <TD width="80%">
79   * A text message to insert into the body of the email.<BR>
80   * Default: no message is inserted.
81   * </TD>
82   * </TR>
83   * <TR valign=top>
84   * <TD width="20%">&lt;inline&gt;</TD>
85   * <TD width="80%">
86   * <P>One of the following items:</P>
87   * <UL>
88   * <LI>unaltered &nbsp;&nbsp;&nbsp;&nbsp;The original message is the new
89   * message, for forwarding/aliasing</LI>
90   * <LI>heads&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The
91   * headers of the original message are appended to the message</LI>
92   * <LI>body&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The
93   * body of the original is appended to the new message</LI>
94   * <LI>all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Both
95   * headers and body are appended</LI>
96   * <LI>none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Neither
97   * body nor headers are appended</LI>
98   * </UL>
99   * Default: &quot;unaltered&quot;.
100  * </TD>
101  * </TR>
102  * <TR valign=top>
103  * <TD width="20%">&lt;attachment&gt;</TD>
104  * <TD width="80%">
105  * <P>One of the following items:</P>
106  * <UL>
107  * <LI>heads&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The headers of the original
108  * are attached as text</LI>
109  * <LI>body&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The body of the original
110  * is attached as text</LI>
111  * <LI>all&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Both
112  * headers and body are attached as a single text file</LI>
113  * <LI>none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nothing is attached</LI>
114  * <LI>message &nbsp;The original message is attached as type message/rfc822,
115  * this means that it can, in many cases, be opened, resent, fw'd, replied
116  * to etc by email client software.</LI>
117  * </UL>
118  * Default: &quot;none&quot;.
119  * </TD>
120  * </TR>
121  * <TR valign=top>
122  * <TD width="20%">&lt;passThrough&gt;</TD>
123  * <TD width="80%">
124  * true or false, if true the original message continues in the
125  * mailet processor after this mailet is finished. False causes the original
126  * to be stopped.<BR>
127  * Default: false.
128  * </TD>
129  * </TR>
130  * <TR valign=top>
131  * <TD width="20%">&lt;fakeDomainCheck&gt;</TD>
132  * <TD width="80%">
133  * true or false, if true will check if the sender domain is valid.<BR>
134  * Default: true.
135  * </TD>
136  * </TR>
137  * <TR valign=top>
138  * <TD width="20%">&lt;attachError&gt;</TD>
139  * <TD width="80%">
140  * true or false, if true any error message available to the
141  * mailet is appended to the message body (except in the case of inline ==
142  * unaltered).<BR>
143  * Default: false.
144  * </TD>
145  * </TR>
146  * <TR valign=top>
147  * <TD width="20%">&lt;replyTo&gt;</TD>
148  * <TD width="80%">
149  * A single email address to appear in the Reply-To: header.<BR>
150  * It can include constants &quot;sender&quot;, &quot;postmaster&quot; &quot;null&quot; and &quot;unaltered&quot;;
151  * if &quot;null&quot; is specified it will remove this header.<BR>
152  * Default: &quot;unaltered&quot;.
153  * </TD>
154  * </TR>
155  * <TR valign=top>
156  * <TD width="20%">&lt;reversePath&gt;</TD>
157  * <TD width="80%">
158  * A single email address to appear in the Return-Path: header.<BR>
159  * It can include constants &quot;sender&quot;, &quot;postmaster&quot; &quot;null&quot; and &quot;unaltered&quot;;
160  * if &quot;null&quot; is specified then it will set it to <>, meaning &quot;null return path&quot;.<BR>
161  * Default: &quot;unaltered&quot;.
162  * </TD>
163  * </TR>
164  * <TR valign=top>
165  * <TD width="20%">&lt;subject&gt;</TD>
166  * <TD width="80%">
167  * An optional string to use as the subject.<BR>
168  * Default: keep the original message subject.
169  * </TD>
170  * </TR>
171  * <TR valign=top>
172  * <TD width="20%">&lt;prefix&gt;</TD>
173  * <TD width="80%">
174  * An optional subject prefix prepended to the original message
175  * subject, or to a new subject specified with the <I>&lt;subject&gt;</I> parameter.<BR>
176  * For example: <I>[Undeliverable mail]</I>.<BR>
177  * Default: &quot;&quot;.
178  * </TD>
179  * </TR>
180  * <TR valign=top>
181  * <TD width="20%">&lt;isReply&gt;</TD>
182  * <TD width="80%">
183  * true or false, if true the IN_REPLY_TO header will be set to the
184  * id of the current message.<BR>
185  * Default: false.
186  * </TD>
187  * </TR>
188  * <TR valign=top>
189  * <TD width="20%">&lt;debug&gt;</TD>
190  * <TD width="80%">
191  * true or false.  If this is true it tells the mailet to write some debugging
192  * information to the mailet log.<BR>
193  * Default: false.
194  * </TD>
195  * </TR>
196  * </TABLE>
197  *
198  * <P>Example:</P>
199  * <PRE><CODE>
200  *  &lt;mailet match=&quot;RecipientIs=test@localhost&quot; class=&quot;Resend&quot;&gt;
201  *    &lt;recipients&gt;x@localhost, y@localhost, z@localhost&lt;/recipients&gt;
202  *    &lt;to&gt;list@localhost&lt;/to&gt;
203  *    &lt;sender&gt;owner@localhost&lt;/sender&gt;
204  *    &lt;message&gt;sent on from James&lt;/message&gt;
205  *    &lt;inline&gt;unaltered&lt;/inline&gt;
206  *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
207  *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
208  *    &lt;prefix xml:space="preserve"&gt;[test mailing] &lt;/prefix&gt;
209  *    &lt;!-- note the xml:space="preserve" to preserve whitespace --&gt;
210  *    &lt;static&gt;TRUE&lt;/static&gt;
211  * &lt;/mailet&gt;
212  * </CODE></PRE>
213  * 
214  * <P>and:</P>
215  *
216  * <PRE><CODE>
217  *  &lt;mailet match=&quot;All&quot; class=&quot;Resend&quot;&gt;
218  *    &lt;recipients&gt;x@localhost&lt;/recipients&gt;
219  *    &lt;sender&gt;postmaster&lt;/sender&gt;
220  *    &lt;message xml:space="preserve"&gt;Message marked as spam:&lt;/message&gt;
221  *    &lt;inline&gt;heads&lt;/inline&gt;
222  *    &lt;attachment&gt;message&lt;/attachment&gt;
223  *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
224  *    &lt;attachError&gt;TRUE&lt;/attachError&gt;
225  *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
226  *    &lt;prefix&gt;[spam notification]&lt;/prefix&gt;
227  *  &lt;/mailet&gt;
228  * </CODE></PRE>
229  *
230  * <P>The following example forwards the message without any modification, based on the defaults:</P>
231  * <PRE><CODE>
232  *  &lt;mailet match=&quot;All&quot; class=&quot;Resend&quot/;&gt;
233  * </CODE></PRE>
234  * <P><I>replyto</I> can be used instead of
235  * <I>replyTo</I>; such name is kept for backward compatibility.</P>
236  * <P><B>WARNING: as the message (or a copy of it) is reinjected in the spool without any modification,
237  * the preceding example is very likely to cause a "configuration loop" in your system,
238  * unless some other mailet has previously modified something (a header for instance) that could force the resent
239  * message follow a different path so that it does not return here unchanged.</B></P>
240  *
241  * @version CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (Mon, 08 Jan 2007) $
242  * @since 2.2.0
243  */
244 
245 public class Resend extends AbstractRedirect {
246 
247     /***
248      * Returns a string describing this mailet.
249      *
250      * @return a string describing this mailet
251      */
252     public String getMailetInfo() {
253         return "Redirect Mailet";
254     }
255 
256     /*** Gets the expected init parameters. */
257     protected  String[] getAllowedInitParameters() {
258         String[] allowedArray = {
259 //            "static",
260             "debug",
261             "passThrough",
262             "fakeDomainCheck",
263             "inline",
264             "attachment",
265             "message",
266             "recipients",
267             "to",
268             "replyTo",
269             "replyto",
270             "reversePath",
271             "sender",
272             "subject",
273             "prefix",
274             "attachError",
275             "isReply"
276         };
277         return allowedArray;
278     }
279 
280     /* ******************************************************************** */
281     /* ****************** Begin of getX and setX methods ****************** */
282     /* ******************************************************************** */
283 
284     /* ******************************************************************** */
285     /* ******************* End of getX and setX methods ******************* */
286     /* ******************************************************************** */
287 
288 }