danny 2002/08/21 03:02:26
Modified: src/java/org/apache/james/transport/mailets Redirect.java
Log:
Changed handling of To: header so that
<to>recipients</to>
in the config will re-use the addresses from the original message's To: header
Revision Changes Path
1.12 +20 -1
jakarta-james/src/java/org/apache/james/transport/mailets/Redirect.java
Index: Redirect.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/Redirect.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Redirect.java 19 Aug 2002 18:57:07 -0000 1.11
+++ Redirect.java 21 Aug 2002 10:02:25 -0000 1.12
@@ -14,8 +14,11 @@
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.Vector;
+
import javax.mail.Message;
import javax.mail.MessagingException;
@@ -70,7 +73,7 @@
*<TD width="80%">A comma delimited list of addresses to appear in the To: header,
*the email will only be delivered to these addresses if they are in the recipients
*list.<BR>
-*The recipients list will be used if this is not supplied</TD>
+*The recipients list will be used if this is not supplied.<BR>The special value
"recipients" in this parameter will cause the addresses in the original To header to
be retained.</TD>
*</TR>
*<TR>
*<TD width="20%"><sender></TD>
@@ -449,6 +452,20 @@
recipients = getRecipients();
apparentlyTo = getTo();
}
+ if(apparentlyTo[0].toString().equalsIgnoreCase("recipients")){
+ apparentlyTo =
(InternetAddress[])mail.getMessage().getRecipients(Message.RecipientType.TO);
+// Collection c = mail.getRecipients();
+// Iterator i = c.iterator();
+// Vector d = new Vector();
+// MailAddress m = null;
+// while(i.hasNext()){
+// m = (MailAddress)i.next();
+// d.add(m.toInternetAddress());
+// }
+// apparentlyTo = (InternetAddress[])d.toArray();
+
+
+ }
MimeMessage message = mail.getMessage();
MimeMessage reply = new
MimeMessage(Session.getDefaultInstance(System.getProperties(),
null));
@@ -534,7 +551,9 @@
if(reply.getHeader("Date") == null) {
reply.setHeader("Date", rfc822DateFormat.format(new Date()));
}
+
reply.setRecipients(Message.RecipientType.TO, apparentlyTo);
+
if(replyTo != null) {
InternetAddress[] iart = new InternetAddress[1];
iart[0] = replyTo.toInternetAddress();
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>