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