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>"unaltered"</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%"><recipients></TD>
39 * <TD width="80%">
40 * A comma delimited list of addresses for recipients of this message.<BR>
41 * Such addresses can contain "full names", like
42 * <I>Mr. John D. Smith <john.smith@xyz.com></I>.<BR>
43 * The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered";
44 * "replyTo" uses the ReplyTo header if available, otherwise the
45 * From header if available, otherwise the Sender header if available, otherwise the return-path;
46 * "from" is made equivalent to "sender", and "to" is made equivalent to "recipients";
47 * "null" is ignored.
48 * Default: "unaltered".
49 * </TD>
50 * </TR>
51 * <TR valign=top>
52 * <TD width="20%"><to></TD>
53 * <TD width="80%">
54 * A comma delimited list of addresses to appear in the To: header.<BR>
55 * Such addresses can contain "full names", like
56 * <I>Mr. John D. Smith <john.smith@xyz.com></I>.<BR>
57 * The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered";
58 * "from" uses the From header if available, otherwise the Sender header if available,
59 * otherwise the return-path;
60 * "replyTo" uses the ReplyTo header if available, otherwise the
61 * From header if available, otherwise the Sender header if available, otherwise the return-path;
62 * "recipients" is made equivalent to "to";
63 * if "null" is specified alone it will remove this header.
64 * Default: "unaltered".
65 * </TD>
66 * </TR>
67 * <TR valign=top>
68 * <TD width="20%"><sender></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 "sender", "postmaster" and "unaltered";
72 * "sender" is equivalent to "unaltered".<BR>
73 * Default: "unaltered".
74 * </TD>
75 * </TR>
76 * <TR valign=top>
77 * <TD width="20%"><message></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%"><inline></TD>
85 * <TD width="80%">
86 * <P>One of the following items:</P>
87 * <UL>
88 * <LI>unaltered The original message is the new
89 * message, for forwarding/aliasing</LI>
90 * <LI>heads The
91 * headers of the original message are appended to the message</LI>
92 * <LI>body The
93 * body of the original is appended to the new message</LI>
94 * <LI>all Both
95 * headers and body are appended</LI>
96 * <LI>none Neither
97 * body nor headers are appended</LI>
98 * </UL>
99 * Default: "unaltered".
100 * </TD>
101 * </TR>
102 * <TR valign=top>
103 * <TD width="20%"><attachment></TD>
104 * <TD width="80%">
105 * <P>One of the following items:</P>
106 * <UL>
107 * <LI>heads The headers of the original
108 * are attached as text</LI>
109 * <LI>body The body of the original
110 * is attached as text</LI>
111 * <LI>all Both
112 * headers and body are attached as a single text file</LI>
113 * <LI>none Nothing is attached</LI>
114 * <LI>message 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: "none".
119 * </TD>
120 * </TR>
121 * <TR valign=top>
122 * <TD width="20%"><passThrough></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%"><fakeDomainCheck></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%"><attachError></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%"><replyTo></TD>
148 * <TD width="80%">
149 * A single email address to appear in the Reply-To: header.<BR>
150 * It can include constants "sender", "postmaster" "null" and "unaltered";
151 * if "null" is specified it will remove this header.<BR>
152 * Default: "unaltered".
153 * </TD>
154 * </TR>
155 * <TR valign=top>
156 * <TD width="20%"><reversePath></TD>
157 * <TD width="80%">
158 * A single email address to appear in the Return-Path: header.<BR>
159 * It can include constants "sender", "postmaster" "null" and "unaltered";
160 * if "null" is specified then it will set it to <>, meaning "null return path".<BR>
161 * Default: "unaltered".
162 * </TD>
163 * </TR>
164 * <TR valign=top>
165 * <TD width="20%"><subject></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%"><prefix></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><subject></I> parameter.<BR>
176 * For example: <I>[Undeliverable mail]</I>.<BR>
177 * Default: "".
178 * </TD>
179 * </TR>
180 * <TR valign=top>
181 * <TD width="20%"><isReply></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%"><debug></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 * <mailet match="RecipientIs=test@localhost" class="Resend">
201 * <recipients>x@localhost, y@localhost, z@localhost</recipients>
202 * <to>list@localhost</to>
203 * <sender>owner@localhost</sender>
204 * <message>sent on from James</message>
205 * <inline>unaltered</inline>
206 * <passThrough>FALSE</passThrough>
207 * <replyTo>postmaster</replyTo>
208 * <prefix xml:space="preserve">[test mailing] </prefix>
209 * <!-- note the xml:space="preserve" to preserve whitespace -->
210 * <static>TRUE</static>
211 * </mailet>
212 * </CODE></PRE>
213 *
214 * <P>and:</P>
215 *
216 * <PRE><CODE>
217 * <mailet match="All" class="Resend">
218 * <recipients>x@localhost</recipients>
219 * <sender>postmaster</sender>
220 * <message xml:space="preserve">Message marked as spam:</message>
221 * <inline>heads</inline>
222 * <attachment>message</attachment>
223 * <passThrough>FALSE</passThrough>
224 * <attachError>TRUE</attachError>
225 * <replyTo>postmaster</replyTo>
226 * <prefix>[spam notification]</prefix>
227 * </mailet>
228 * </CODE></PRE>
229 *
230 * <P>The following example forwards the message without any modification, based on the defaults:</P>
231 * <PRE><CODE>
232 * <mailet match="All" class="Resend"/;>
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
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
282
283
284
285
286
287
288 }