You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by se...@apache.org on 2002/05/25 16:37:04 UTC
cvs commit: jakarta-james/src/java/org/apache/james/transport/mailets GenericListserv.java
serge 02/05/25 07:37:04
Modified: src/java/org/apache/james/transport/mailets
GenericListserv.java
Log:
Sets an X-been-there header and then looks for it in any messages. This should stop straightforward bounces from getting sent again over the listserv.
Revision Changes Path
1.4 +25 -7 jakarta-james/src/java/org/apache/james/transport/mailets/GenericListserv.java
Index: GenericListserv.java
===================================================================
RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/GenericListserv.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GenericListserv.java 18 Jan 2002 02:48:38 -0000 1.3
+++ GenericListserv.java 25 May 2002 14:37:04 -0000 1.4
@@ -84,7 +84,25 @@
return;
}
- MimeMessage message = mail.getMessage();
+ //Create a copy of this message to send out
+ MimeMessage message = new MimeMessage(mail.getMessage());
+ //We need to remove this header from the copy we're sending around
+ message.removeHeader("Return-Path");
+
+ //Figure out the listserv address.
+ MailAddress listservAddr = getListservAddress();
+ if (listservAddr == null) {
+ //Use the recipient
+ listservAddr = (MailAddress)mail.getRecipients().iterator().next();
+ }
+
+ //Check if the X-been-there header is set to the listserv's name
+ // (the address). If it has, this means it's a message from this
+ // listserv that's getting bounced back, so we need to swallow it
+ if (listservAddr.equals(message.getHeader("X-been-there"))) {
+ mail.setState(Mail.GHOST);
+ return;
+ }
//Set the subject if set
if (getSubjectPrefix() != null) {
@@ -106,18 +124,18 @@
}
message.setSubject(subj);
}
- MailAddress listservAddr = getListservAddress();
- if (listservAddr == null) {
- //Use the recipient
- listservAddr = (MailAddress)mail.getRecipients().iterator().next();
- }
+ //If replies should go to this list, we need to set the header
if (isReplyToList()) {
message.setHeader("Reply-To", listservAddr.toString());
}
+ //We're going to set this special header to avoid bounces
+ // getting sent back out to the list
+ message.setHeader("X-been-there", listservAddr.toString());
//Send the message to the list members
- getMailetContext().sendMail(listservAddr, members, message);
+ //We set the postmaster as the sender for now so bounces go to him/her
+ getMailetContext().sendMail(getMailetContext().getPostmaster(), members, message);
//Kill the old message
mail.setState(Mail.GHOST);
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>