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