vincenzo 2003/06/27 07:15:13 Added: src/java/org/apache/james/transport/mailets Resend.java Log: . Revision Changes Path 1.1 jakarta-james/src/java/org/apache/james/transport/mailets/Resend.java Index: Resend.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache", "Jakarta", "JAMES" and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. */ package org.apache.james.transport.mailets; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Collection; import java.util.Date; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.Locale; import java.util.StringTokenizer; import java.util.ArrayList; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import org.apache.james.core.MailImpl; import org.apache.mailet.GenericMailet; import org.apache.mailet.Mail; import org.apache.mailet.MailAddress; /** * <P>A mailet providing configurable redirection services.</P> * <P>Can produce listserver, forward and notify behaviour, with the original * message intact, attached, appended or left out altogether. * Should be used as a replacement to [EMAIL PROTECTED] Redirect}, as defaults are more consistent, * and has new options available.</P> * <P>This built in functionality is controlled by the configuration as laid out below. * In the table please note that the parameters controlling message headers * accept the <B>"unaltered"</B> value, whose meaning is to keep the associated * header unchanged and, unless stated differently, corresponds to the assumed default * if the parameter is missing.</P> * <P>The configuration parameters are:</P> * <TABLE width="75%" border="1" cellspacing="2" cellpadding="2"> * <TR valign=top> * <TD width="20%"><recipients></TD> * <TD width="80%"> * A comma delimited list of email addresses for recipients of * this message;.<BR> * It can include constants "sender", "postmaster", "returnPath" and "unaltered".<BR> * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><to></TD> * <TD width="80%"> * A comma delimited list of addresses to appear in the To: header;.<BR> * It can include constants "sender", "postmaster", "returnPath" and "unaltered". * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><sender></TD> * <TD width="80%"> * A single email address to appear in the From: header and become the sender.<BR> * It can include constants "sender", "postmaster" and "unaltered"; * if "sender" is specified then it will follow a safe procedure from the * original From: header (see [EMAIL PROTECTED] AbstractRedirect#setSender} and [EMAIL PROTECTED] AbstractRedirect#getSender(Mail)}).<BR> * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><message></TD> * <TD width="80%"> * A text message to insert into the body of the email.<BR> * Default: no message is inserted. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><inline></TD> * <TD width="80%"> * <P>One of the following items:</P> * <UL> * <LI>unaltered The original message is the new * message, for forwarding/aliasing</LI> * <LI>heads The * headers of the original message are appended to the message</LI> * <LI>body The * body of the original is appended to the new message</LI> * <LI>all Both * headers and body are appended</LI> * <LI>none Neither * body nor headers are appended</LI> * </UL> * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><attachment></TD> * <TD width="80%"> * <P>One of the following items:</P> * <UL> * <LI>heads The headers of the original * are attached as text</LI> * <LI>body The body of the original * is attached as text</LI> * <LI>all Both * headers and body are attached as a single text file</LI> * <LI>none Nothing is attached</LI> * <LI>message The original message is attached as type message/rfc822, * this means that it can, in many cases, be opened, resent, fw'd, replied * to etc by email client software.</LI> * </UL> * Default: "none". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><passThrough></TD> * <TD width="80%"> * true or false, if true the original message continues in the * mailet processor after this mailet is finished. False causes the original * to be stopped.<BR> * Default: false. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><fakeDomainCheck></TD> * <TD width="80%"> * true or false, if true will check if the sender domain is valid.<BR> * Default: true. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><attachError></TD> * <TD width="80%"> * true or false, if true any error message available to the * mailet is appended to the message body (except in the case of inline == * unaltered).<BR> * Default: false. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><replyto></TD> * <TD width="80%"> * A single email address to appear in the Reply-To: header.<BR> * It can include constants "sender", "postmaster" "null" and "unaltered"; * if "sender" is specified then it will follow a safe procedure from the * original From: header (see [EMAIL PROTECTED] AbstractRedirect#setReplyTo} and [EMAIL PROTECTED] AbstractRedirect#getReplyTo(Mail)}); * if "null" is specified it will remove this header.<BR> * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><returnPath></TD> * <TD width="80%"> * A single email address to appear in the Return-Path: header.<BR> * It can include constants "sender", "postmaster" "null"and "unaltered"; * if "null" is specified then it will set it to <>, meaning "null return path".<BR> * Default: "unaltered". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><subject></TD> * <TD width="80%"> * An optional string to use as the subject.<BR> * Default: keep the original message subject. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><prefix></TD> * <TD width="80%"> * An optional subject prefix prepended to the original message * subject, or to a new subject specified with the <I><subject></I> parameter.<BR> * For example: <I>[Undeliverable mail]</I>.<BR> * Default: "". * </TD> * </TR> * <TR valign=top> * <TD width="20%"><isReply></TD> * <TD width="80%"> * true or false, if true the IN_REPLY_TO header will be set to the * id of the current message.<BR> * Default: false. * </TD> * </TR> * <TR valign=top> * <TD width="20%"><debug></TD> * <TD width="80%"> * true or false. If this is true it tells the mailet to write some debugging * information to the mailet log.<BR> * Default: false. * </TD> * </TR> * </TABLE> * * <P>Example:</P> * <PRE><CODE> * <mailet match="[EMAIL PROTECTED]" class="Resend"> * <recipients>[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]</recipients> * <to>[EMAIL PROTECTED]</to> * <sender>[EMAIL PROTECTED]</sender> * <message>sent on from James</message> * <inline>unaltered</inline> * <passThrough>FALSE</passThrough> * <replyto>postmaster</replyto> * <prefix xml:space="preserve">[test mailing] </prefix> * <!-- note the xml:space="preserve" to preserve whitespace --> * <static>TRUE</static> * </mailet> * </CODE></PRE> * * <P>and:</P> * * <PRE><CODE> * <mailet match="All" class="Resend"> * <recipients>[EMAIL PROTECTED]</recipients> * <sender>postmaster</sender> * <message xml:space="preserve">Message marked as spam:</message> * <inline>heads</inline> * <attachment>message</attachment> * <passThrough>FALSE</passThrough> * <attachError>TRUE</attachError> * <replyto>postmaster</replyto> * <prefix>[spam notification]</prefix> * </mailet> * </CODE></PRE> * * <P>The following example forwards the message without any modification, based on the defaults:</P> * <PRE><CODE> * <mailet match="All" class="Resend"/;> * </CODE></PRE> * <P><B>WARNING: as the message (or a copy of it) is reinjected in the spool without any modification, * the preceding example is very likely to cause a "configuration loop" in your system, * unless some other mailet has previously modified something (a header for instance) that could force the resent * message follow a different path so that it does not return here unchanged.</B></P> * * @version CVS $Revision: 1.1 $ $Date: 2003/06/27 14:15:13 $ * @since 2.2.0 */ public class Resend extends AbstractRedirect { /** * Returns a string describing this mailet. * * @return a string describing this mailet */ public String getMailetInfo() { return "Redirect Mailet"; } /** Gets the expected init parameters. */ protected String[] getAllowedInitParameters() { String[] allowedArray = { // "static", "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "recipients", "to", "replyto", "returnPath", "sender", "subject", "prefix", "attachError", "isReply" }; return allowedArray; } /* ******************************************************************** */ /* ****************** Begin of getX and setX methods ****************** */ /* ******************************************************************** */ /* ******************************************************************** */ /* ******************* End of getX and setX methods ******************* */ /* ******************************************************************** */ }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]