james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vince...@apache.org
Subject cvs commit: james-server/src/java/org/apache/james/transport/mailets AbstractNotify.java AbstractRedirect.java Bounce.java Forward.java NotifyPostmaster.java NotifySender.java Redirect.java Resend.java
Date Fri, 04 Jul 2003 16:42:18 GMT
vincenzo    2003/07/04 09:42:17

  Modified:    src/java/org/apache/james/transport/mailets Tag:
                        branch_2_1_fcs AbstractNotify.java
                        AbstractRedirect.java Bounce.java Forward.java
                        NotifyPostmaster.java NotifySender.java
                        Redirect.java Resend.java
  Log:
  1) Added <forwardTo> to the Forward mailet, and <replyTo> to all mailets.
  2) Better exception reporting.
  3) Now throwing a MessagingException if a getX() ends up with an empty (not null) list or array.
  4) Changed consistently return-path (and its variations) to reverse-path (and variations); the Return-Path header is always built from the reverse-path when this is changed.
  5) The <recipients> and the <to> parameters can accept SpecialAddress-es mixed with real addresses.
  6) Corrected all bounce-like functionality.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.9   +27 -20    james-server/src/java/org/apache/james/transport/mailets/AbstractNotify.java
  
  Index: AbstractNotify.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/AbstractNotify.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- AbstractNotify.java	30 Jun 2003 09:42:07 -0000	1.1.2.8
  +++ AbstractNotify.java	4 Jul 2003 16:42:17 -0000	1.1.2.9
  @@ -113,8 +113,8 @@
    *   &lt;debug&gt;<I>true or false, default=false</I>&lt;/debug&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
  - * <P><I>notice</I>, <I>senderAddress</I> and <I>attachStackTrace</I> can be used instead of
  - * <I><I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
  + * <P><I>notice</I> and <I>senderAddress</I> can be used instead of
  + * <I>message</I> and <I>sender</I>; such names are kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    * @since 2.2.0
  @@ -260,7 +260,7 @@
       /**
        * @return {@link AbstractRedirect#getSender(Mail)}, meaning the new requested sender if any
        */
  -    protected MailAddress getReturnPath(Mail originalMail) throws MessagingException {
  +    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
           return getSender(originalMail);
       }
   
  @@ -289,23 +289,30 @@
       }
   
       /**
  -     * @return the <CODE>attachStackTrace</CODE> init parameter, 
  -     * or the <CODE>attachError</CODE> init parameter if missing,
  -     * or false if missing 
  -     */
  -    protected boolean attachError() {
  -        boolean attachStackTrace = false;
  -        try {
  -            attachStackTrace = new Boolean(getInitParameter("attachStackTrace")).booleanValue();
  -        } catch (Exception e) {
  -            // try with attachError
  -            try {
  -                attachStackTrace = new Boolean(getInitParameter("attachError")).booleanValue();
  -            } catch (Exception e2) {
  -                // Ignore exception, default to false
  -            }
  +     * @return the <CODE>prefix</CODE> init parameter or "Re:" if missing
  +     */
  +    protected String getSubjectPrefix() {
  +        if(getInitParameter("prefix") == null) {
  +            return "Re:";
  +        } else {
  +            return getInitParameter("prefix");
  +        }
  +    }
  +
  +    /**
  +     * Builds the subject of <I>newMail</I> appending the subject
  +     * of <I>originalMail</I> to <I>subjectPrefix</I>, but avoiding a duplicate.
  +     */
  +    protected void setSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
  +        String subject = originalMail.getMessage().getSubject();
  +        if (subject == null) {
  +            subject = "";
  +        }
  +        if (subject.indexOf(subjectPrefix) == 0) {
  +            newMail.getMessage().setSubject(subject);
  +        } else {
  +            newMail.getMessage().setSubject(subjectPrefix + subject);
           }
  -        return attachStackTrace;
       }
   
       /**
  
  
  
  1.1.2.17  +231 -204  james-server/src/java/org/apache/james/transport/mailets/AbstractRedirect.java
  
  Index: AbstractRedirect.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/AbstractRedirect.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- AbstractRedirect.java	3 Jul 2003 08:32:30 -0000	1.1.2.16
  +++ AbstractRedirect.java	4 Jul 2003 16:42:17 -0000	1.1.2.17
  @@ -78,6 +78,7 @@
   import javax.mail.internet.MimeBodyPart;
   import javax.mail.internet.MimeMessage;
   import javax.mail.internet.MimeMultipart;
  +import javax.mail.internet.AddressException;
   
   import org.apache.james.util.RFC2822Headers;
   import org.apache.james.util.RFC822DateFormat;
  @@ -101,7 +102,7 @@
    * <LI>getMessage(), The text of the message itself</LI>
    * <LI>getRecipients(), the recipients the mail is sent to</LI>
    * <LI>getReplyTo(), where replies to this message will be sent</LI>
  - * <LI>getReturnPath(), what to set the Return-Path to</LI>
  + * <LI>getReversePath(), what to set the reverse-path to</LI>
    * <LI>getSender(), who the mail is from</LI>
    * <LI>getSubject(), a string to replace the message subject</LI>
    * <LI>getSubjectPrefix(), a prefix to be added to the message subject, possibly already replaced by a new subject</LI>
  @@ -191,7 +192,7 @@
   
       private static class AddressMarker {
           public static MailAddress SENDER;
  -        public static MailAddress RETURN_PATH;
  +        public static MailAddress REVERSE_PATH;
           public static MailAddress TO;
           public static MailAddress RECIPIENTS;
           public static MailAddress DELETE;
  @@ -200,13 +201,13 @@
   
           static {
               try {
  -                SENDER      = new MailAddress("sender","address.marker");
  -                RETURN_PATH = new MailAddress("return.path","address.marker");
  -                TO          = new MailAddress("to","address.marker");
  -                RECIPIENTS  = new MailAddress("recipients","address.marker");
  -                DELETE      = new MailAddress("delete","address.marker");
  -                UNALTERED   = new MailAddress("unaltered","address.marker");
  -                NULL        = new MailAddress("null","address.marker");
  +                SENDER          = new MailAddress("sender","address.marker");
  +                REVERSE_PATH    = new MailAddress("reverse.path","address.marker");
  +                TO              = new MailAddress("to","address.marker");
  +                RECIPIENTS      = new MailAddress("recipients","address.marker");
  +                DELETE          = new MailAddress("delete","address.marker");
  +                UNALTERED       = new MailAddress("unaltered","address.marker");
  +                NULL            = new MailAddress("null","address.marker");
   
               } catch (Exception _) {}
           }
  @@ -218,13 +219,13 @@
        * by a "getX(Mail)" or "setX(Mail, Tx, Mail)".
        */
       protected static class SpecialAddress {
  -        public static final MailAddress SENDER      = AddressMarker.SENDER;
  -        public static final MailAddress RETURN_PATH = AddressMarker.RETURN_PATH;
  -        public static final MailAddress TO          = AddressMarker.TO;
  -        public static final MailAddress RECIPIENTS  = AddressMarker.RECIPIENTS;
  -        public static final MailAddress DELETE      = AddressMarker.DELETE;
  -        public static final MailAddress UNALTERED   = AddressMarker.UNALTERED;
  -        public static final MailAddress NULL        = AddressMarker.NULL;
  +        public static final MailAddress SENDER          = AddressMarker.SENDER;
  +        public static final MailAddress REVERSE_PATH    = AddressMarker.REVERSE_PATH;
  +        public static final MailAddress TO              = AddressMarker.TO;
  +        public static final MailAddress RECIPIENTS      = AddressMarker.RECIPIENTS;
  +        public static final MailAddress DELETE          = AddressMarker.DELETE;
  +        public static final MailAddress UNALTERED       = AddressMarker.UNALTERED;
  +        public static final MailAddress NULL            = AddressMarker.NULL;
       }
   
       // The values that indicate how to attach the original mail
  @@ -249,7 +250,7 @@
       private String messageText;
       private Collection recipients;
       private MailAddress replyTo;
  -    private MailAddress returnPath;
  +    private MailAddress reversePath;
       private MailAddress sender;
       private String subject;
       private String subjectPrefix;
  @@ -265,7 +266,7 @@
   
       /**
        * <P>Gets the <CODE>static</CODE> property.</P>
  -     * <P>Return true to reduce calls to getTo, getSender, getRecipients, getReplyTo, getReturnPath amd getMessage
  +     * <P>Return true to reduce calls to getTo, getSender, getRecipients, getReplyTo, getReversePath amd getMessage
        * where these values don't change (eg hard coded, or got at startup from the mailet config);
        * return false where any of these methods generate their results dynamically eg in response to the message being processed,
        * or by reference to a repository of users.</P>
  @@ -290,11 +291,7 @@
        * @return the <CODE>passThrough</CODE> init parameter, or false if missing
        */
       protected boolean getPassThrough() throws MessagingException {
  -        if(getInitParameter("passThrough") == null) {
  -            return false;
  -        } else {
  -            return new Boolean(getInitParameter("passThrough")).booleanValue();
  -        }
  +        return new Boolean(getInitParameter("passThrough")).booleanValue();
       }
   
       /**
  @@ -317,11 +314,7 @@
        * @return the <CODE>fakeDomainCheck</CODE> init parameter, or true if missing
        */
       protected boolean getFakeDomainCheck() throws MessagingException {
  -        if(getInitParameter("fakeDomainCheck") == null) {
  -            return true;
  -        } else {
  -            return new Boolean(getInitParameter("fakeDomainCheck")).booleanValue();
  -        }
  +        return new Boolean(getInitParameter("fakeDomainCheck")).booleanValue();
       }
   
       /**
  @@ -442,12 +435,14 @@
        * @return the <CODE>recipients</CODE> init parameter
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
  -     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
        * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>SpecialAddress.RECIPIENTS</CODE>
        * or <CODE>null</CODE> if missing
        */
       protected Collection getRecipients() throws MessagingException {
           Collection newRecipients = new HashSet();
  +        boolean error = false;
           String addressList = getInitParameter("recipients");
           
           // if nothing was specified, return <CODE>null</CODE> meaning no change
  @@ -455,23 +450,30 @@
               return null;
           }
   
  -        MailAddress specialAddress = getSpecialAddress(addressList,
  -                                        new String[] {"postmaster", "sender", "returnPath", "unaltered"});
  -        if (specialAddress != null) {
  -            newRecipients.add(specialAddress);
  -            return newRecipients;
  -        }
  -
           StringTokenizer st = new StringTokenizer(addressList, ",", false);
           while(st.hasMoreTokens()) {
               String token = null;
               try {
                   token = st.nextToken();
  -                newRecipients.add(new MailAddress(token));
  +                MailAddress specialAddress = getSpecialAddress(token,
  +                                                new String[] {"postmaster", "sender", "reversePath", "unaltered", "recipients"});
  +                if (specialAddress != null) {
  +                    newRecipients.add(specialAddress);
  +                } else {
  +                    newRecipients.add(new MailAddress(token));
  +                }
               } catch(Exception e) {
  -                throw new MessagingException("Exception thrown in getRecipients() parsing: " + token, e);
  +                error = true;
  +                log("Exception thrown in getRecipients() parsing: " + token, e);
               }
           }
  +        if (error) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; see mailet log.");
  +        }
  +        if (newRecipients.size() == 0) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
  +        }
  +
           return newRecipients;
       }
   
  @@ -480,31 +482,15 @@
        * built dynamically using the original Mail object.
        * Is a "getX(Mail)" method.
        *
  -     * @return {@link #getRecipients()},
  -     * replacing <CODE>SpecialAddress.SENDER</CODE> if applicable with the original sender
  -     * and <CODE>SpecialAddress.UNALTERED</CODE>
  -     * and <CODE>SpecialAddress.RECIPIENTS</CODE> if applicable with null
  +     * @return {@link #replaceMailAddresses} on {@link #getRecipients()},
        */
       protected Collection getRecipients(Mail originalMail) throws MessagingException {
           Collection recipients = (isStatic()) ? this.recipients : getRecipients();
  -        if (recipients != null && recipients.size() == 1) {
  -            if (recipients.contains(SpecialAddress.UNALTERED) || recipients.contains(SpecialAddress.RECIPIENTS)) {
  +        if (recipients != null) {
  +            if (recipients.size() == 1 && (recipients.contains(SpecialAddress.UNALTERED) || recipients.contains(SpecialAddress.RECIPIENTS))) {
                   recipients = null;
  -            } else if (recipients.contains(SpecialAddress.SENDER)) {
  -                recipients = new ArrayList();
  -                recipients.add(originalMail.getSender());
  -            } else if (recipients.contains(SpecialAddress.RETURN_PATH)) {
  -                recipients = new ArrayList();
  -                MailAddress mailAddress = getExistingReturnPath(originalMail);
  -                if (mailAddress == SpecialAddress.NULL) {
  -                    // should never get here
  -                    throw new MessagingException("NULL return path found getting recipients");
  -                }
  -                if (mailAddress == null) {
  -                    recipients.add(originalMail.getSender());
  -                } else {
  -                    recipients.add(mailAddress);
  -                }
  +            } else {
  +                recipients = replaceMailAddresses(originalMail, recipients);
               }
           }
           return recipients;
  @@ -533,37 +519,46 @@
        * @return the <CODE>to</CODE> init parameter
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
  -     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
        * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>SpecialAddress.TO</CODE>
        * or <CODE>null</CODE> if missing
        */
       protected InternetAddress[] getTo() throws MessagingException {
  +        boolean error = false;
           String addressList = getInitParameter("to");
  +        
           // if nothing was specified, return null meaning no change
           if (addressList == null) {
               return null;
           }
   
  -        MailAddress specialAddress = getSpecialAddress(addressList,
  -                                        new String[] {"postmaster", "sender", "returnPath", "unaltered"});
  -        if (specialAddress != null) {
  -            InternetAddress[] iaarray = new InternetAddress[1];
  -            iaarray[0] = specialAddress.toInternetAddress();
  -            return iaarray;
  -        }
  -
  -        StringTokenizer rec       = new StringTokenizer(addressList, ",");
  -        int tokensn               = rec.countTokens();
  -        InternetAddress[] iaarray = new InternetAddress[tokensn];
  -        String tokenx             = "";
  -        for(int i = 0; i < tokensn; ++i) {
  +        StringTokenizer rec = new StringTokenizer(addressList, ",");
  +        int tokenCount = rec.countTokens();
  +        InternetAddress[] iaarray = new InternetAddress[tokenCount];
  +        String token = "";
  +        for(int i = 0; i < tokenCount; ++i) {
               try {
  -                tokenx     = rec.nextToken();
  -                iaarray[i] = new InternetAddress(tokenx);
  +                token = rec.nextToken();
  +                MailAddress specialAddress = getSpecialAddress(token,
  +                                                new String[] {"postmaster", "sender", "reversePath", "unaltered", "to", "null"});
  +                if (specialAddress != null) {
  +                    iaarray[i] = specialAddress.toInternetAddress();
  +                } else {
  +                    iaarray[i] = new InternetAddress(token);
  +                }
               } catch(Exception e) {
  -                throw new MessagingException("Exception thrown in getTo() parsing: " + tokenx, e);
  +                error = true;
  +                log("Exception thrown in getTo() parsing: " + token, e);
               }
           }
  +        if (error) {
  +            throw new MessagingException("Failed to initialize \"to\" list; see mailet log.");
  +        }
  +        if (tokenCount == 0) {
  +            throw new MessagingException("Failed to initialize \"to\" list; empty <to> init parameter found.");
  +        }
  +
           return iaarray;
       }
   
  @@ -573,81 +568,29 @@
        * Its outcome will be the the value the <I>TO:</I> header will be set to,
        * that could be different from the real recipient (see {@link #getRecipients}).
        * Is a "getX(Mail)" method.
  -     * <P>The logic is the following, based on {@link #getTo()}:</P>
  -     * <UL>
  -     *      <LI>
  -     *          If <CODE>getTo()</CODE> returns null it returns null, meaning no change.
  -     *      </LI>
  -     *      <LI>
  -     *          If <CODE>getTo()</CODE> returns <CODE>SpecialAddress.SENDER</CODE>
  -     *          it returns the <I>sender</I>;
  -     *          if the <I>sender</I> is null it returns the <I>Return-Path:</I> header;
  -     *          if the <I>Return-Path:</I> header does not exist or == <CODE>SpecialAddress.NULL</CODE> ("<>") it returns "<>".
  -     *      </LI>
  -     *      <LI>
  -     *          If <CODE>getTo()</CODE> returns <CODE>SpecialAddress.UNALTERED</CODE>
  -     *                                          or <CODE>SpecialAddress.TO</CODE>
  -     *          it returns the original <I>TO:</I>.
  -     *      </LI>
  -     *      <LI>
  -     *          If <CODE>getTo()</CODE> returns <CODE>SpecialAddress.RETURN_PATH</CODE>
  -     *          it returns the contents of the <I>Return-Path:</I> header;
  -     *          if the <I>Return-Path:</I> header is <CODE>SpecialAddress.NULL</CODE> it throws a <CODE>MessagingException</CODE>;
  -     *          if the <I>Return-Path:</I> header does not exist it returns the <I>sender</I>;
  -     *          if the <I>sender</I> is null it returns "<>".
  -     *      </LI>
  -     * </UL>
  -     *
  -     * @return {@link #getTo()}, replacing <CODE>SpecialAddress.SENDER</CODE>,
  -     * <CODE>SpecialAddress.SENDER</CODE>,
  -     * <CODE>SpecialAddress.TO</CODE>,
  -     * and <CODE>SpecialAddress.UNALTERED</CODE> if applicable
  +     *
  +     * @return {@link #replaceInternetAddresses} on {@link #getRecipients()},
        */
       protected InternetAddress[] getTo(Mail originalMail) throws MessagingException {
           InternetAddress[] apparentlyTo = (isStatic()) ? this.apparentlyTo : getTo();
  -        if (apparentlyTo != null && apparentlyTo.length == 1) {
  -            if (apparentlyTo[0].equals(SpecialAddress.SENDER.toInternetAddress())) {
  -                MailAddress mailAddress = originalMail.getSender();
  -                if (mailAddress == null) {
  -                    mailAddress = getExistingReturnPath(originalMail);
  -                    if (mailAddress == SpecialAddress.NULL) {
  -                        mailAddress = null;
  -                    }
  -                }
  -                if (mailAddress == null) {
  -                    /* IMPORTANT: setTo() treats null differently from
  -                     * an zero length array, so do not just use null
  -                     */
  -                    // set to <>
  -                    apparentlyTo = new InternetAddress[0];
  -                } else {
  -                    apparentlyTo = new InternetAddress[1];
  -                    apparentlyTo[0] = mailAddress.toInternetAddress();
  -                }
  -            } else if (apparentlyTo[0].equals(SpecialAddress.UNALTERED.toInternetAddress())
  -                       || apparentlyTo[0].equals(SpecialAddress.TO.toInternetAddress())) {
  -                apparentlyTo = (InternetAddress[]) originalMail.getMessage().getRecipients(Message.RecipientType.TO);
  -            } else if (apparentlyTo[0].equals(SpecialAddress.RETURN_PATH.toInternetAddress())) {
  -                MailAddress mailAddress = getExistingReturnPath(originalMail);
  -                if (mailAddress == SpecialAddress.NULL) {
  -                    // should never get here
  -                    throw new MessagingException("NULL return path found getting recipients");
  -                }
  -                if (mailAddress == null) {
  -                    mailAddress = originalMail.getSender();
  -                }
  -                if (mailAddress == null) {
  -                    /* IMPORTANT: setTo() treats null differently from
  -                     * an zero length array, so do not just use null
  -                     */
  -                    // set to <>
  -                    apparentlyTo = new InternetAddress[0];
  -                } else {
  -                    apparentlyTo = new InternetAddress[1];
  -                    apparentlyTo[0] = mailAddress.toInternetAddress();
  +        if (apparentlyTo != null) {
  +            if (   apparentlyTo.length == 1
  +                && (   apparentlyTo[0].equals(SpecialAddress.UNALTERED.toInternetAddress())
  +                    || apparentlyTo[0].equals(SpecialAddress.TO.toInternetAddress())
  +                    )) {
  +                apparentlyTo = null;
  +            } else {
  +                Collection toList = new ArrayList(apparentlyTo.length);
  +                for (int i = 0; i < apparentlyTo.length; i++) {
  +                    toList.add(apparentlyTo[i]);
                   }
  +                /* IMPORTANT: setTo() treats null differently from a zero length array,
  +                  so it's ok to get a zero length array from replaceSpecialAddresses
  +                 */
  +                apparentlyTo = (InternetAddress[]) replaceInternetAddresses(originalMail, toList).toArray(new InternetAddress[0]);
               }
           }
  +        
           return apparentlyTo;
       }
   
  @@ -679,7 +622,10 @@
        * or <CODE>null</CODE> if missing
        */
       protected MailAddress getReplyTo() throws MessagingException {
  -        String addressString = getInitParameter("replyto");
  +        String addressString = getInitParameter("replyTo");
  +        if (addressString == null) {
  +            addressString = getInitParameter("replyto");
  +        }
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
                                               new String[] {"postmaster", "sender", "null", "unaltered"});
  @@ -742,20 +688,20 @@
       }
   
       /**
  -     * Gets the <CODE>returnPath</CODE> property.
  -     * Returns the Return-Path of the new message,
  +     * Gets the <CODE>reversePath</CODE> property.
  +     * Returns the reverse-path of the new message,
        * or null if no change is requested.
        * Is a "getX()" method.
        *
  -     * @return the <CODE>returnPath</CODE> init parameter 
  +     * @return the <CODE>reversePath</CODE> init parameter 
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
        * or <CODE>SpecialAddress.NULL</CODE>
        * or <CODE>SpecialAddress.UNALTERED</CODE>
        * or <CODE>null</CODE> if missing
        */
  -    protected MailAddress getReturnPath() throws MessagingException {
  -        String addressString = getInitParameter("returnPath");
  +    protected MailAddress getReversePath() throws MessagingException {
  +        String addressString = getInitParameter("reversePath");
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
                                               new String[] {"postmaster", "sender", "null", "unaltered"});
  @@ -766,7 +712,7 @@
               try {
                   return new MailAddress(addressString);
               } catch(Exception e) {
  -                throw new MessagingException("Exception thrown in getReturnPath() parsing: " + addressString, e);
  +                throw new MessagingException("Exception thrown in getReversePath() parsing: " + addressString, e);
               }
           }
   
  @@ -774,47 +720,49 @@
       }
   
       /**
  -     * Gets the <CODE>returnPath</CODE> property,
  +     * Gets the <CODE>reversePath</CODE> property,
        * built dynamically using the original Mail object.
        * Is a "getX(Mail)" method.
        *
  -     * @return {@link #getReturnPath()},
  -     * replacing <CODE>SpecialAddress.SENDER</CODE> if applicable with the original sender,
  +     * @return {@link #getReversePath()},
  +     * replacing <CODE>SpecialAddress.SENDER</CODE> if applicable with null,
        * replacing <CODE>SpecialAddress.UNALTERED</CODE>
  -     * and <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null,
  +     * and <CODE>SpecialAddress.REVERSE_PATH</CODE> if applicable with null,
        * but not replacing <CODE>SpecialAddress.NULL</CODE>
  -     * that will be handled by {@link #setReturnPath}
  +     * that will be handled by {@link #setReversePath}
        */
  -    protected MailAddress getReturnPath(Mail originalMail) throws MessagingException {
  -        MailAddress returnPath = (isStatic()) ? this.returnPath : getReturnPath();
  -        if (returnPath != null) {
  -            if (returnPath == SpecialAddress.UNALTERED || returnPath == SpecialAddress.RETURN_PATH) {
  -                returnPath = null;
  +    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
  +        MailAddress reversePath = (isStatic()) ? this.reversePath : getReversePath();
  +        if (reversePath != null) {
  +            if (reversePath == SpecialAddress.UNALTERED || reversePath == SpecialAddress.REVERSE_PATH) {
  +                reversePath = null;
               }
  -            else if (returnPath == SpecialAddress.SENDER) {
  -                returnPath = originalMail.getSender();
  +            else if (reversePath == SpecialAddress.SENDER) {
  +                reversePath = null;
               }
           }
  -        return returnPath;
  +        return reversePath;
       }
   
       /**
  -     * Sets the "Return-Path:" header of <I>newMail</I> to <I>returnPath</I>.
  +     * Sets the "reverse-path" of <I>newMail</I> to <I>reversePath</I>.
        * If the requested value is <CODE>SpecialAddress.NULL</CODE> sets it to "<>".
        * If the requested value is null does nothing.
        * Is a "setX(Mail, Tx, Mail)" method.
        */
  -    protected void setReturnPath(Mail newMail, MailAddress returnPath, Mail originalMail) throws MessagingException {
  -        if(returnPath != null) {
  -            String returnPathString;
  -            if (returnPath == SpecialAddress.NULL) {
  -                returnPathString = "";
  +    protected void setReversePath(Mail newMail, MailAddress reversePath, Mail originalMail) throws MessagingException {
  +        if(reversePath != null) {
  +            String reversePathString;
  +            if (reversePath == SpecialAddress.NULL) {
  +                reversePath = null;
  +                reversePathString = "";
               } else {
  -                returnPathString = returnPath.toString();
  +                reversePathString = reversePath.toString();
               }
  -            newMail.getMessage().setHeader(RFC2822Headers.RETURN_PATH, "<" + returnPathString + ">");
  +            ((MailImpl) newMail).setSender(reversePath);
  +            newMail.getMessage().setHeader(RFC2822Headers.RETURN_PATH, "<" + reversePathString + ">");
               if (isDebug) {
  -                log("returnPath set to: " + returnPath);
  +                log("reversePath set to: " + reversePath);
               }
           }
       }
  @@ -870,14 +818,13 @@
       }
   
       /**
  -     * Sets the sender and the "From:" header of <I>newMail</I> to <I>sender</I>.
  +     * Sets the "From:" header of <I>newMail</I> to <I>sender</I>.
        * If the requested value is null does nothing.
        * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setSender(Mail newMail, MailAddress sender, Mail originalMail) throws MessagingException {
           if (sender != null) {
               newMail.getMessage().setFrom(sender.toInternetAddress());
  -            ((MailImpl) newMail).setSender(sender);
               
               if (isDebug) {
                   log("sender set to: " + sender);
  @@ -981,11 +928,7 @@
        * @return the <CODE>attachError</CODE> init parameter; false if missing
        */
       protected boolean attachError() throws MessagingException {
  -        if(getInitParameter("attachError") == null) {
  -            return false;
  -        } else {
  -            return new Boolean(getInitParameter("attachError")).booleanValue();
  -        }
  +        return new Boolean(getInitParameter("attachError")).booleanValue();
       }
   
       /**
  @@ -1010,9 +953,6 @@
        * @return the <CODE>isReply</CODE> init parameter; false if missing
        */
       protected boolean isReply() throws MessagingException {
  -        if(getInitParameter("isReply") == null) {
  -            return false;
  -        }
           return new Boolean(getInitParameter("isReply")).booleanValue();
       }
   
  @@ -1066,20 +1006,20 @@
           checkInitParameters(getAllowedInitParameters());
           
           if(isStatic()) {
  -            passThrough     = getPassThrough();
  -            fakeDomainCheck = getFakeDomainCheck();
  -            attachmentType  = getAttachmentType();
  -            inLineType      = getInLineType();
  -            messageText     = getMessage();
  -            recipients      = getRecipients();
  -            replyTo         = getReplyTo();
  -            returnPath      = getReturnPath();
  -            sender          = getSender();
  -            subject         = getSubject();
  -            subjectPrefix   = getSubjectPrefix();
  -            apparentlyTo    = getTo();
  -            attachError     = attachError();
  -            isReply         = isReply();
  +            passThrough         = getPassThrough();
  +            fakeDomainCheck     = getFakeDomainCheck();
  +            attachmentType      = getAttachmentType();
  +            inLineType          = getInLineType();
  +            messageText         = getMessage();
  +            recipients          = getRecipients();
  +            replyTo             = getReplyTo();
  +            reversePath         = getReversePath();
  +            sender              = getSender();
  +            subject             = getSubject();
  +            subjectPrefix       = getSubjectPrefix();
  +            apparentlyTo        = getTo();
  +            attachError         = attachError();
  +            isReply             = isReply();
               if (isDebug) {
                   StringBuffer logBuffer =
                       new StringBuffer(1024)
  @@ -1088,7 +1028,7 @@
                               .append(", fakeDomainCheck=").append(fakeDomainCheck)
                               .append(", sender=").append(sender)
                               .append(", replyTo=").append(replyTo)
  -                            .append(", returnPath=").append(returnPath)
  +                            .append(", reversePath=").append(reversePath)
                               .append(", message=").append(messageText)
                               .append(", recipients=").append(arrayToString(recipients == null ? null : recipients.toArray()))
                               .append(", subject=").append(subject)
  @@ -1182,7 +1122,7 @@
   
           setReplyTo(newMail, getReplyTo(originalMail), originalMail);
   
  -        setReturnPath(newMail, getReturnPath(originalMail), originalMail);
  +        setReversePath(newMail, getReversePath(originalMail), originalMail);
   
           setSender(newMail, getSender(originalMail), originalMail);
   
  @@ -1283,7 +1223,7 @@
       }
   
       /**
  -     * Gets the MailAddress corresponding to the existing "Return-Path" header of
  +     * Gets the MailAddress corresponding to the existing "Return-Path" of
        * <I>mail</I>.
        * If empty returns <CODE>SpecialAddress.NULL</CODE>,
        * if missing return <CODE>null</CODE>.
  @@ -1581,8 +1521,8 @@
           if(addressString.compareTo("sender") == 0) {
               specialAddress = SpecialAddress.SENDER;
           }
  -        if(addressString.compareTo("returnpath") == 0) {
  -            specialAddress = SpecialAddress.RETURN_PATH;
  +        if(addressString.compareTo("reversepath") == 0) {
  +            specialAddress = SpecialAddress.REVERSE_PATH;
           }
           if(addressString.compareTo("to") == 0) {
               specialAddress = SpecialAddress.TO;
  @@ -1760,6 +1700,93 @@
           if (-1 == rawText.indexOf("?=", iThirdQuestionMark + 1)) return null; // closing tag
           String mimeCharset = rawText.substring(iCharsetBegin, iSecondQuestionMark);
           return mimeCharset;
  +    }
  +    
  +    /**
  +     * Returns a new Collection built over <I>list</I> replacing special addresses
  +     * with real ones.
  +     * Manages <CODE>SpecialAddress.SENDER</CODE>, <CODE>SpecialAddress.REVERSE_PATH</CODE>,
  +     * <CODE>SpecialAddress.RECIPIENTS</CODE>, 
  +     * <CODE>SpecialAddress.NULL</CODE> and <CODE>SpecialAddress.UNALTERED</CODE>.
  +     * Any other address is not replaced.
  +     */
  +    protected Collection replaceMailAddresses(Mail mail, Collection list) {
  +        Collection newList = new HashSet(list.size());
  +        Iterator iterator = list.iterator();
  +        while (iterator.hasNext()) {
  +            MailAddress mailAddress = (MailAddress) iterator.next();
  +            if (!mailAddress.getHost().equalsIgnoreCase("address.marker")) {
  +                newList.add(mailAddress);
  +            } else if (mailAddress == SpecialAddress.SENDER) {
  +                MailAddress sender = mail.getSender();
  +                if (sender != null) {
  +                    newList.add(sender);
  +                }
  +            } else if (mailAddress == SpecialAddress.REVERSE_PATH) {
  +                MailAddress reversePath = mail.getSender();
  +                if (reversePath != null) {
  +                    newList.add(reversePath);
  +                }
  +            } else if (mailAddress == SpecialAddress.RECIPIENTS) {
  +                newList.addAll(mail.getRecipients());
  +            } else if (mailAddress == SpecialAddress.UNALTERED) {
  +                continue;
  +            } else {
  +                newList.add(mailAddress);
  +            }
  +        }
  +        return newList;
  +    }
  +
  +    /**
  +     * Returns a new Collection built over <I>list</I> replacing special addresses
  +     * with real ones.
  +     * Manages <CODE>SpecialAddress.SENDER</CODE>, <CODE>SpecialAddress.REVERSE_PATH</CODE>,
  +     * <CODE>SpecialAddress.TO</CODE>, 
  +     * <CODE>SpecialAddress.NULL</CODE> and <CODE>SpecialAddress.UNALTERED</CODE>.
  +     * Any other address is not replaced.
  +     */
  +    protected Collection replaceInternetAddresses(Mail mail, Collection list) throws MessagingException {
  +        Collection newList = new HashSet(list.size());
  +        Iterator iterator = list.iterator();
  +        while (iterator.hasNext()) {
  +            InternetAddress internetAddress = (InternetAddress) iterator.next();
  +            MailAddress mailAddress = new MailAddress(internetAddress);
  +            if (!mailAddress.getHost().equalsIgnoreCase("address.marker")) {
  +                newList.add(internetAddress);
  +            } else if (internetAddress.equals(SpecialAddress.SENDER.toInternetAddress())) {
  +                MailAddress sender = mail.getSender();
  +                if (sender != null) {
  +                    newList.add(sender.toInternetAddress());
  +                }
  +            } else if (internetAddress.equals(SpecialAddress.REVERSE_PATH.toInternetAddress())) {
  +                MailAddress reversePath = mail.getSender();
  +                if (reversePath != null) {
  +                    newList.add(reversePath.toInternetAddress());
  +                }
  +            } else if (internetAddress.equals(SpecialAddress.TO.toInternetAddress())) {
  +                String[] toHeaders = mail.getMessage().getHeader(RFC2822Headers.TO);
  +                if (toHeaders != null) {
  +                    for (int i = 0; i < toHeaders.length; i++) {
  +                        try {
  +                            InternetAddress[] originalToInternetAddresses = InternetAddress.parse(toHeaders[i], false);
  +                            for (int j = 0; j < originalToInternetAddresses.length; j++) {
  +                                newList.add(originalToInternetAddresses[j]);
  +                            }
  +                        } catch (AddressException ae) {
  +                            log("Unable to parse the \"TO\" header in the original message: " + toHeaders[i] + "; ignoring.");
  +                        }
  +                    }
  +                }
  +            } else if (internetAddress.equals(SpecialAddress.UNALTERED.toInternetAddress())) {
  +                continue;
  +            } else if (internetAddress.equals(SpecialAddress.NULL.toInternetAddress())) {
  +                continue;
  +            } else {
  +                newList.add(internetAddress);
  +            }
  +        }
  +        return newList;
       }
   
   }
  
  
  
  1.1.2.9   +14 -16    james-server/src/java/org/apache/james/transport/mailets/Bounce.java
  
  Index: Bounce.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/Bounce.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- Bounce.java	30 Jun 2003 09:42:07 -0000	1.1.2.8
  +++ Bounce.java	4 Jul 2003 16:42:17 -0000	1.1.2.9
  @@ -83,13 +83,12 @@
   import java.util.ArrayList;
   
   /**
  - * <P>Generates a response to the Return-Path address, or the
  - * address of the message's sender if the Return-Path is not
  - * available. Note that this is different than a mail-client's
  + * <P>Generates a response to the reverse-path address.
  + * Note that this is different than a mail-client's
    * reply, which would use the Reply-To or From header.</P>
    * <P>Bounced messages are attached in their entirety (headers and
    * content) and the resulting MIME part type is "message/rfc822".<BR>
  - * The Return-Path header of the response is set to "null" ("<>"),
  + * The reverse-path and the Return-Path header of the response is set to "null" ("<>"),
    * meaning that no reply should be sent.</P>
    * <P>A sender of the notification message can optionally be specified.
    * If one is not specified, the postmaster's address will be used.<BR>
  @@ -126,15 +125,15 @@
    *   &lt;passThrough&gt;true or false&lt;/passThrough&gt;
    *   &lt;fakeDomainCheck&gt;<I>true or false</I>&lt;/fakeDomainCheck&gt;
    *   &lt;recipients&gt;<B>sender</B>&lt;/recipients&gt;
  - *   &lt;returnPath&gt;null&lt;/returnPath&gt;
  + *   &lt;reversePath&gt;null&lt;/reversePath&gt;
    *   &lt;inline&gt;see {@link Resend}&lt;/inline&gt;
    *   &lt;attachment&gt;see {@link Resend}&lt;/attachment&gt;
    *   &lt;isReply&gt;true&lt;/isReply&gt;
    *   &lt;debug&gt;<I>true or false</I>&lt;/debug&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
  - * <P><I>notice</I>, <I>sendingAddress</I> and <I>attachStackTrace</I> can be used instead of
  - * <I><I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
  + * <P><I>notice</I> and <I>sendingAddress</I> can be used instead of
  + * <I>message</I> and <I>sender</I>; such names are kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    * @since 2.2.0
  @@ -165,7 +164,6 @@
               "sendingAddress",
               "prefix",
               "attachError",
  -            "attachStackTrace"
           };
           return allowedArray;
       }
  @@ -175,27 +173,27 @@
       /* ******************************************************************** */
   
       /**
  -     * @return <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * @return <CODE>SpecialAddress.REVERSE_PATH</CODE>
        */
       protected Collection getRecipients() {
           Collection newRecipients = new HashSet();
  -        newRecipients.add(SpecialAddress.RETURN_PATH);
  +        newRecipients.add(SpecialAddress.REVERSE_PATH);
           return newRecipients;
       }
   
       /**
  -     * @return <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * @return <CODE>SpecialAddress.REVERSE_PATH</CODE>
        */
       protected InternetAddress[] getTo() {
           InternetAddress[] apparentlyTo = new InternetAddress[1];
  -        apparentlyTo[0] = SpecialAddress.RETURN_PATH.toInternetAddress();
  +        apparentlyTo[0] = SpecialAddress.REVERSE_PATH.toInternetAddress();
           return apparentlyTo;
       }
   
       /**
        * @return <CODE>SpecialAddress.NULL</CODE> (the meaning of bounce)
        */
  -    protected MailAddress getReturnPath(Mail originalMail) {
  +    protected MailAddress getReversePath(Mail originalMail) {
           return SpecialAddress.NULL;
       }
   
  @@ -215,13 +213,13 @@
           MailAddress returnAddress = getExistingReturnPath(originalMail);
           if (returnAddress == SpecialAddress.NULL) {
               if (isDebug)
  -                log("Processing a bounce request for a message with an empty return path.  No bounce will be sent.");
  +                log("Processing a bounce request for a message with an empty reverse-path.  No bounce will be sent.");
               if(!getPassThrough(originalMail)) {
                   originalMail.setState(Mail.GHOST);
               }
               return;
           } else if (returnAddress == null) {
  -            log("WARNING: Mail to be bounced does not contain a Return-Path header.");
  +            log("WARNING: Mail to be bounced does not contain a reverse-path.");
           } else {
               if (isDebug)
                   log("Processing a bounce request for a message with a return path header.  The bounce will be sent to " + returnAddress);
  
  
  
  1.6.4.11  +36 -17    james-server/src/java/org/apache/james/transport/mailets/Forward.java
  
  Index: Forward.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/Forward.java,v
  retrieving revision 1.6.4.10
  retrieving revision 1.6.4.11
  diff -u -r1.6.4.10 -r1.6.4.11
  --- Forward.java	3 Jul 2003 05:25:30 -0000	1.6.4.10
  +++ Forward.java	4 Jul 2003 16:42:17 -0000	1.6.4.11
  @@ -76,7 +76,7 @@
    * <P>Sample configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="Forward">
  - *   &lt;forwardto&gt;<I>comma delimited list of email addresses</I>&lt;/forwardto&gt;
  + *   &lt;forwardTo&gt;<I>comma delimited list of email addresses</I>&lt;/forwardTo&gt;
    *   &lt;passThrough&gt;<I>true or false, default=false</I>&lt;/passThrough&gt;
    *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
    *   &lt;debug&gt;<I>true or false, default=false</I>&lt;/debug&gt;
  @@ -93,6 +93,8 @@
    *   &lt;debug&gt;<I>true or false</I>&lt;/debug&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
  + * <P><I>forwardto</I> can be used instead of
  + * <I>forwardTo</I>; such name is kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    */
  @@ -115,6 +117,7 @@
               "passThrough",
               "fakeDomainCheck",
               "forwardto",
  +            "forwardTo"
           };
           return allowedArray;
       }
  @@ -148,24 +151,40 @@
        * @return the <CODE>recipients</CODE> init parameter or null if missing
        */
       protected Collection getRecipients() throws MessagingException {
  -        Collection newRecipients = null;
  +        Collection newRecipients = new HashSet();
           boolean error = false;
           String addressList = getInitParameter("forwardto");
  -        if (addressList != null) {
  -            newRecipients = new HashSet();
  -            StringTokenizer st = new StringTokenizer(addressList, ",", false);
  -            while(st.hasMoreTokens()) {
  -                String recipient = st.nextToken();
  -                try {
  -                    newRecipients.add(new MailAddress(recipient));
  -                } catch(Exception e) {
  -                    log("Add \"" + recipient + "\" failed", e);
  -                    error = true;
  +        if (addressList == null) {
  +            addressList = getInitParameter("forwardTo");
  +        }
  +        
  +        // if nothing was specified, throw an exception
  +        if (addressList == null) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list: no <forwardTo> or <forwardto> init parameter found");
  +        }
  +
  +        StringTokenizer st = new StringTokenizer(addressList, ",", false);
  +        while(st.hasMoreTokens()) {
  +            String token = null;
  +            try {
  +                token = st.nextToken();
  +                MailAddress specialAddress = getSpecialAddress(token,
  +                                                new String[] {"postmaster", "sender", "reversePath", "unaltered", "recipients"});
  +                if (specialAddress != null) {
  +                    newRecipients.add(specialAddress);
  +                } else {
  +                    newRecipients.add(new MailAddress(token));
                   }
  +            } catch(Exception e) {
  +                error = true;
  +                log("Exception thrown in getRecipients() parsing: " + token, e);
               }
           }
  -        if (error || newRecipients == null || newRecipients.size() == 0) {
  -            throw new MessagingException("Failed to initialize recipient list; see mailet log.");
  +        if (error) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; see mailet log.");
  +        }
  +        if (newRecipients.size() == 0) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; empty <forwardTo> or <forwardto> init parameter found.");
           }
   
           return newRecipients;
  @@ -188,7 +207,7 @@
       /**
        * @return null
        */
  -    protected MailAddress getReturnPath() throws MessagingException {
  +    protected MailAddress getReversePath() throws MessagingException {
           return null;
       }
   
  @@ -216,7 +235,7 @@
       /**
        * @return false
        */
  -    protected boolean attachError() throws MessagingException {
  +    protected boolean attachError() {
           return false;
       }
   
  
  
  
  1.9.4.11  +11 -25    james-server/src/java/org/apache/james/transport/mailets/NotifyPostmaster.java
  
  Index: NotifyPostmaster.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/NotifyPostmaster.java,v
  retrieving revision 1.9.4.10
  retrieving revision 1.9.4.11
  diff -u -r1.9.4.10 -r1.9.4.11
  --- NotifyPostmaster.java	30 Jun 2003 09:42:07 -0000	1.9.4.10
  +++ NotifyPostmaster.java	4 Jul 2003 16:42:17 -0000	1.9.4.11
  @@ -130,7 +130,7 @@
    * &lt;/mailet&gt;
    * </CODE></PRE>
    * <P><I>notice</I>, <I>sendingAddress</I> and <I>attachStackTrace</I> can be used instead of
  - * <I><I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
  + * <I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    */
  @@ -199,30 +199,16 @@
       }
   
       /**
  -     * @return the <CODE>prefix</CODE> init parameter or "Re:" if missing
  +     * @return the <CODE>attachStackTrace</CODE> init parameter, 
  +     * or the <CODE>attachError</CODE> init parameter if missing,
  +     * or false if missing 
        */
  -    protected String getSubjectPrefix() {
  -        if(getInitParameter("prefix") == null) {
  -            return "Re:";
  -        } else {
  -            return getInitParameter("prefix");
  -        }
  -    }
  -
  -    /**
  -     * Builds the subject of <I>newMail</I> appending the subject
  -     * of <I>originalMail</I> to <I>subjectPrefix</I>, but avoiding a duplicate.
  -     */
  -    protected void setSubjectPrefix(Mail newMail, String subjectPrefix, Mail originalMail) throws MessagingException {
  -        String subject = originalMail.getMessage().getSubject();
  -        if (subject == null) {
  -            subject = "";
  -        }
  -        if (subject.indexOf(subjectPrefix) == 0) {
  -            newMail.getMessage().setSubject(subject);
  -        } else {
  -            newMail.getMessage().setSubject(subjectPrefix + subject);
  -        }
  +    protected boolean attachError() throws MessagingException {
  +        String parameter = getInitParameter("attachStackTrace");
  +        if (parameter == null) {
  +            return super.attachError();
  +        }        
  +        return new Boolean(parameter).booleanValue();
       }
   
       /* ******************************************************************** */
  
  
  
  1.10.4.12 +15 -2     james-server/src/java/org/apache/james/transport/mailets/NotifySender.java
  
  Index: NotifySender.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/NotifySender.java,v
  retrieving revision 1.10.4.11
  retrieving revision 1.10.4.12
  diff -u -r1.10.4.11 -r1.10.4.12
  --- NotifySender.java	30 Jun 2003 09:42:07 -0000	1.10.4.11
  +++ NotifySender.java	4 Jul 2003 16:42:17 -0000	1.10.4.12
  @@ -129,7 +129,7 @@
    * &lt;/mailet&gt;
    * </CODE></PRE>
    * <P><I>notice</I>, <I>sendingAddress</I> and <I>attachStackTrace</I> can be used instead of
  - * <I><I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
  + * <I>message</I>, <I>sender</I> and <I>attachError</I>; such names are kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    */
  @@ -195,6 +195,19 @@
               }
           }
           return iaarray;
  +    }
  +
  +    /**
  +     * @return the <CODE>attachStackTrace</CODE> init parameter, 
  +     * or the <CODE>attachError</CODE> init parameter if missing,
  +     * or false if missing 
  +     */
  +    protected boolean attachError() throws MessagingException {
  +        String parameter = getInitParameter("attachStackTrace");
  +        if (parameter == null) {
  +            return super.attachError();
  +        }        
  +        return new Boolean(parameter).booleanValue();
       }
   
       /* ******************************************************************** */
  
  
  
  1.18.4.15 +69 -46    james-server/src/java/org/apache/james/transport/mailets/Redirect.java
  
  Index: Redirect.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/Redirect.java,v
  retrieving revision 1.18.4.14
  retrieving revision 1.18.4.15
  diff -u -r1.18.4.14 -r1.18.4.15
  --- Redirect.java	30 Jun 2003 09:42:07 -0000	1.18.4.14
  +++ Redirect.java	4 Jul 2003 16:42:17 -0000	1.18.4.15
  @@ -93,7 +93,7 @@
    * <P>It differs from {@link Resend} because
    * (i) some defaults are different,
    * notably for the following parameters: <I>&lt;recipients&gt;</I>, <I>&lt;to&gt;</I>,
  - * <I>&lt;returnPath&gt;</I> and <I>&lt;inline&gt;</I>;
  + * <I>&lt;reversePath&gt;</I> and <I>&lt;inline&gt;</I>;
    * (ii) because it allows the use of the <I>&lt;static&gt;</I> parameter;.<BR>
    * Use <CODE>Resend</CODE> if you need full control, <CODE>Redirect</CODE> if
    * the more automatic behaviour of some parameters is appropriate.</P>
  @@ -112,7 +112,7 @@
    * if none of the lists is specified.<BR>
    * These addresses will only appear in the To: header if no &quot;to&quot; list is
    * supplied.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;returnPath&quot; and &quot;unaltered&quot;.
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;recipients&quot; and &quot;unaltered&quot;.
    * </TD>
    * </TR>
    * <TR valign=top>
  @@ -123,7 +123,8 @@
    * list.<BR>
    * The recipients list will be used if this list is not supplied;
    * if none of the lists is specified it will be &quot;unaltered&quot;.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;returnPath&quot; and &quot;unaltered&quot;.
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;recipients&quot;, &quot;null&quot; and &quot;unaltered&quot;;
  + * if &quot;null&quot; is specified alone it will remove this header.
    * </TD>
    * </TR>
    * <TR valign=top>
  @@ -206,7 +207,7 @@
    * </TD>
    * </TR>
    * <TR valign=top>
  - * <TD width="20%">&lt;replyto&gt;</TD>
  + * <TD width="20%">&lt;replyTo&gt;</TD>
    * <TD width="80%">
    * A single email address to appear in the Reply-To: header.<BR>
    * It can include constants &quot;sender&quot;, &quot;postmaster&quot; &quot;null&quot; and &quot;unaltered&quot;;
  @@ -216,7 +217,7 @@
    * </TR>
    * </TR>
    * <TR valign=top>
  - * <TD width="20%">&lt;returnPath&gt;</TD>
  + * <TD width="20%">&lt;reversePath&gt;</TD>
    * <TD width="80%">
    * A single email address to appear in the Return-Path: header.<BR>
    * It can include constants &quot;sender&quot;, &quot;postmaster&quot; and &quot;null&quot;;
  @@ -279,7 +280,7 @@
    *    &lt;message&gt;sent on from James&lt;/message&gt;
    *    &lt;inline&gt;unaltered&lt;/inline&gt;
    *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
  - *    &lt;replyto&gt;postmaster&lt;/replyto&gt;
  + *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
    *    &lt;prefix xml:space="preserve"&gt;[test mailing] &lt;/prefix&gt;
    *    &lt;!-- note the xml:space="preserve" to preserve whitespace --&gt;
    *    &lt;static&gt;TRUE&lt;/static&gt;
  @@ -297,11 +298,13 @@
    *    &lt;attachment&gt;message&lt;/attachment&gt;
    *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
    *    &lt;attachError&gt;TRUE&lt;/attachError&gt;
  - *    &lt;replyto&gt;postmaster&lt;/replyto&gt;
  + *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
    *    &lt;prefix&gt;[spam notification]&lt;/prefix&gt;
    *    &lt;static&gt;TRUE&lt;/static&gt;
    *  &lt;/mailet&gt;
    * </CODE></PRE>
  + * <P><I>replyto</I> can be used instead of
  + * <I>replyTo</I>; such name is kept for backward compatibility.</P>
    *
    * @version CVS $Revision$ $Date$
    */
  @@ -329,8 +332,9 @@
               "message",
               "recipients",
               "to",
  +            "replyTo",
               "replyto",
  -            "returnPath",
  +            "reversePath",
               "sender",
               "subject",
               "prefix",
  @@ -366,36 +370,47 @@
        * @return the <CODE>recipients</CODE> init parameter
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
  -     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
        * or <CODE>SpecialAddress.UNALTERED</CODE>
        * or the <CODE>to</CODE> init parameter if missing
        * or <CODE>null</CODE> if also the latter is missing
        */
       protected Collection getRecipients() throws MessagingException {
           Collection newRecipients = new HashSet();
  +        boolean error = false;
           String addressList = (getInitParameter("recipients") == null)
                                    ? getInitParameter("to")
                                    : getInitParameter("recipients");
  +                                 
           // if nothing was specified, return <CODE>null</CODE> meaning no change
           if (addressList == null) {
               return null;
           }
   
  -        MailAddress specialAddress = getSpecialAddress(addressList,
  -                                        new String[] {"postmaster", "sender", "returnPath", "unaltered"});
  -        if (specialAddress != null) {
  -            newRecipients.add(specialAddress);
  -            return newRecipients;
  -        }
  -
           StringTokenizer st = new StringTokenizer(addressList, ",", false);
           while(st.hasMoreTokens()) {
  +            String token = null;
               try {
  -                newRecipients.add(new MailAddress(st.nextToken()));
  +                token = st.nextToken();
  +                MailAddress specialAddress = getSpecialAddress(token,
  +                                                new String[] {"postmaster", "sender", "reversePath", "unaltered", "recipients"});
  +                if (specialAddress != null) {
  +                    newRecipients.add(specialAddress);
  +                } else {
  +                    newRecipients.add(new MailAddress(token));
  +                }
               } catch(Exception e) {
  -                log("add recipient failed in getRecipients");
  +                error = true;
  +                log("Exception thrown in getRecipients() parsing: " + token, e);
               }
           }
  +        if (error) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; see mailet log.");
  +        }
  +        if (newRecipients.size() == 0) {
  +            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");
  +        }
  +        
           return newRecipients;
       }
   
  @@ -403,52 +418,60 @@
        * @return the <CODE>to</CODE> init parameter
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
  -     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>
        * or <CODE>SpecialAddress.UNALTERED</CODE>
        * or the <CODE>recipients</CODE> init parameter if missing
        * or <CODE>null</CODE> if also the latter is missing
        */
       protected InternetAddress[] getTo() throws MessagingException {
  +        boolean error = false;
           String addressList = (getInitParameter("to") == null)
                                    ? getInitParameter("recipients")
                                    : getInitParameter("to");
  +
           // if nothing was specified, return null meaning no change
           if (addressList == null) {
               return null;
           }
   
  -        MailAddress specialAddress = getSpecialAddress(addressList,
  -                                        new String[] {"postmaster", "sender", "returnPath", "unaltered"});
  -        if (specialAddress != null) {
  -            InternetAddress[] iaarray = new InternetAddress[1];
  -            iaarray[0] = specialAddress.toInternetAddress();
  -            return iaarray;
  -        }
  -
  -        StringTokenizer rec       = new StringTokenizer(addressList, ",");
  -        int tokensn               = rec.countTokens();
  -        InternetAddress[] iaarray = new InternetAddress[tokensn];
  -        String tokenx             = "";
  -        for(int i = 0; i < tokensn; ++i) {
  +        StringTokenizer rec = new StringTokenizer(addressList, ",");
  +        int tokenCount = rec.countTokens();
  +        InternetAddress[] iaarray = new InternetAddress[tokenCount];
  +        String token = "";
  +        for(int i = 0; i < tokenCount; ++i) {
               try {
  -                tokenx     = rec.nextToken();
  -                iaarray[i] = new InternetAddress(tokenx);
  +                token = rec.nextToken();
  +                MailAddress specialAddress = getSpecialAddress(token,
  +                                                new String[] {"postmaster", "sender", "reversePath", "unaltered", "to", "null"});
  +                if (specialAddress != null) {
  +                    iaarray[i] = specialAddress.toInternetAddress();
  +                } else {
  +                    iaarray[i] = new InternetAddress(token);
  +                }
               } catch(Exception e) {
  -                log("Internet address exception in getTo()");
  +                error = true;
  +                log("Exception thrown in getTo() parsing: " + token, e);
               }
           }
  +        if (error) {
  +            throw new MessagingException("Failed to initialize \"to\" list; see mailet log.");
  +        }
  +        if (tokenCount == 0) {
  +            throw new MessagingException("Failed to initialize \"to\" list; empty <to> init parameter found.");
  +        }
  +
           return iaarray;
       }
   
       /**
  -     * @return the <CODE>returnPath</CODE> init parameter 
  +     * @return the <CODE>reversePath</CODE> init parameter 
        * or the postmaster address
        * or <CODE>SpecialAddress.SENDER</CODE>
        * or <CODE>SpecialAddress.NULL</CODE>
        * or <CODE>null</CODE> if missing
        */
  -    protected MailAddress getReturnPath() throws MessagingException {
  -        String addressString = getInitParameter("returnPath");
  +    protected MailAddress getReversePath() throws MessagingException {
  +        String addressString = getInitParameter("reversePath");
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
                                               new String[] {"postmaster", "sender", "null"});
  @@ -459,7 +482,7 @@
               try {
                   return new MailAddress(addressString);
               } catch(Exception e) {
  -                throw new MessagingException("Exception thrown in getReturnPath() parsing: " + addressString, e);
  +                throw new MessagingException("Exception thrown in getReversePath() parsing: " + addressString, e);
               }
           }
   
  @@ -467,16 +490,16 @@
       }
   
       /**
  -     * @return {@link AbstractRedirect#getReturnPath()};
  +     * @return {@link AbstractRedirect#getReversePath()};
        * if null return {@link AbstractRedirect#getSender(Mail)},
        * meaning the new requested sender if any
        */
  -    protected MailAddress getReturnPath(Mail originalMail) throws MessagingException {
  -        MailAddress returnPath = super.getReturnPath(originalMail);
  -        if (returnPath == null) {
  -            returnPath = getSender(originalMail);
  +    protected MailAddress getReversePath(Mail originalMail) throws MessagingException {
  +        MailAddress reversePath = super.getReversePath(originalMail);
  +        if (reversePath == null) {
  +            reversePath = getSender(originalMail);
           }
  -        return returnPath;
  +        return reversePath;
       }
   
       /* ******************************************************************** */
  
  
  
  1.1.2.3   +12 -8     james-server/src/java/org/apache/james/transport/mailets/Resend.java
  
  Index: Resend.java
  ===================================================================
  RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/Resend.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Resend.java	30 Jun 2003 09:42:07 -0000	1.1.2.2
  +++ Resend.java	4 Jul 2003 16:42:17 -0000	1.1.2.3
  @@ -106,7 +106,7 @@
    * <TD width="80%">
    * A comma delimited list of email addresses for recipients of
    * this message;.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;returnPath&quot; and &quot;unaltered&quot;.<BR>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;recipients&quot; and &quot;unaltered&quot;.<BR>
    * Default: &quot;unaltered&quot;.
    * </TD>
    * </TR>
  @@ -114,7 +114,8 @@
    * <TD width="20%">&lt;to&gt;</TD>
    * <TD width="80%">
    * A comma delimited list of addresses to appear in the To: header;.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;returnPath&quot; and &quot;unaltered&quot;.
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;, &quot;reversePath&quot;, &quot;to&quot;, &quot;null&quot; and &quot;unaltered&quot;;
  + * if &quot;null&quot; is specified alone it will remove this header.<BR>
    * Default: &quot;unaltered&quot;.
    * </TD>
    * </TR>
  @@ -198,7 +199,7 @@
    * </TD>
    * </TR>
    * <TR valign=top>
  - * <TD width="20%">&lt;replyto&gt;</TD>
  + * <TD width="20%">&lt;replyTo&gt;</TD>
    * <TD width="80%">
    * A single email address to appear in the Reply-To: header.<BR>
    * It can include constants &quot;sender&quot;, &quot;postmaster&quot; &quot;null&quot; and &quot;unaltered&quot;;
  @@ -207,7 +208,7 @@
    * </TD>
    * </TR>
    * <TR valign=top>
  - * <TD width="20%">&lt;returnPath&gt;</TD>
  + * <TD width="20%">&lt;reversePath&gt;</TD>
    * <TD width="80%">
    * A single email address to appear in the Return-Path: header.<BR>
    * It can include constants &quot;sender&quot;, &quot;postmaster&quot; &quot;null&quot; and &quot;unaltered&quot;;
  @@ -258,7 +259,7 @@
    *    &lt;message&gt;sent on from James&lt;/message&gt;
    *    &lt;inline&gt;unaltered&lt;/inline&gt;
    *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
  - *    &lt;replyto&gt;postmaster&lt;/replyto&gt;
  + *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
    *    &lt;prefix xml:space="preserve"&gt;[test mailing] &lt;/prefix&gt;
    *    &lt;!-- note the xml:space="preserve" to preserve whitespace --&gt;
    *    &lt;static&gt;TRUE&lt;/static&gt;
  @@ -276,7 +277,7 @@
    *    &lt;attachment&gt;message&lt;/attachment&gt;
    *    &lt;passThrough&gt;FALSE&lt;/passThrough&gt;
    *    &lt;attachError&gt;TRUE&lt;/attachError&gt;
  - *    &lt;replyto&gt;postmaster&lt;/replyto&gt;
  + *    &lt;replyTo&gt;postmaster&lt;/replyTo&gt;
    *    &lt;prefix&gt;[spam notification]&lt;/prefix&gt;
    *  &lt;/mailet&gt;
    * </CODE></PRE>
  @@ -285,6 +286,8 @@
    * <PRE><CODE>
    *  &lt;mailet match=&quot;All&quot; class=&quot;Resend&quot/;&gt;
    * </CODE></PRE>
  + * <P><I>replyto</I> can be used instead of
  + * <I>replyTo</I>; such name is kept for backward compatibility.</P>
    * <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
  @@ -317,8 +320,9 @@
               "message",
               "recipients",
               "to",
  +            "replyTo",
               "replyto",
  -            "returnPath",
  +            "reversePath",
               "sender",
               "subject",
               "prefix",
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message