pgoldstein 2002/08/18 01:55:33
Modified: src/java/org/apache/james/transport/mailets Forward.java
Log:
Check for valid sender address before forwarding.
Thanks to Noel Bergman for the patch
Revision Changes Path
1.4 +20 -2
jakarta-james/src/java/org/apache/james/transport/mailets/Forward.java
Index: Forward.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/Forward.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Forward.java 18 Jun 2002 21:39:52 -0000 1.3
+++ Forward.java 18 Aug 2002 08:55:33 -0000 1.4
@@ -17,7 +17,7 @@
import java.util.StringTokenizer;
/**
- * Replace incoming recipient with specified ones.
+ * Replaces incoming recipients with those specified.
*
* @author Federico Barbieri <[EMAIL PROTECTED]>
* @author Serge Knystautas <[EMAIL PROTECTED]>
@@ -35,7 +35,25 @@
}
public void service(Mail mail) throws MessagingException {
- getMailetContext().sendMail(mail.getSender(), newRecipients,
mail.getMessage());
+ if (mail.getSender() == null ||
getMailetContext().getMailServers(mail.getSender().getHost()).size() != 0) {
+ // If we do not do this check, and somone uses Forward in a
+ // processor initiated by SenderInFakeDomain, then a fake
+ // sender domain will cause an infinite loop (the forwarded
+ // e-mail still appears to come from a fake domain).
+ // Although this can be viewed as a configuration error, the
+ // consequences of such a mis-configuration are severe enough
+ // to warrant protecting against the infinite loop.
+ getMailetContext().sendMail(mail.getSender(), newRecipients,
mail.getMessage());
+ }
+ else {
+ StringBuffer logBuffer = new StringBuffer(256)
+ .append("Forward mailet cannot forward ")
+ .append(mail)
+ .append(". Invalid sender domain for ")
+ .append(mail.getSender())
+ .append(". Consider using the Redirect mailet.");
+ log(logBuffer.toString());
+ }
if(! (new Boolean(getInitParameter("passThrough"))).booleanValue()) {
mail.setState(Mail.GHOST);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>