On Wed, 5 Sep 2001, Jacques Lema wrote:
> I have a page on my site (http://maplante.meet-u.com/) that allows (in
> order to offer a virtual plant) sending email to another person.
>
> Apparently if both the TO and the FROM user name are invalid
> for example: sending from "[EMAIL PROTECTED]" to "[EMAIL PROTECTED] "
>
> The mail enter an infinite loop... as it is refused and sent to bob.. who
> doesnt exist, who doesnt exist and sends it to bob... and so on?
>
> How should I filter this? (Using James 1.2.1)
I use the following inside the <spoolmanager> element in
config.xml (which was james-config.xml):
<processor name="transport">
<mailet match="RemoteAddrNotInNetwork=<your networks>"
class="ToProcessor">
<processor> spam </processor>
</mailet>
<!-- local filter -->
<mailet match="HostIs=<your domain>"
class="ToProcessor">
<processor>localproc</processor>
</mailet>
<mailet match="All" class="ToProcessor">
<processor>internet</processor>
</mailet>
</processor>
<processor name="localproc">
<!-- local delivery -->
<mailet match="RecipientIsLocal" class="LocalDelivery">
</mailet>
<!-- nice feature; but could lead to a "ping of death" of your
mail server; the choice is yours -->
<mailet match="All" class="NotifySender">
<notice>We're sorry. Your email could not be delivered; no such
user(s).</notice>
</mailet>
</processor>
<processor name="internet">
<mailet match="SenderHostIsNot=<your domain>" class="ToRepository">
<repositoryPath>db://Message2/wrongsender</repositoryPath>
<passThrough>false</passThrough>
</mailet>
<mailet match="All" class="RemoteDelivery">
<!-- the setting is as usual -->
</mailet>
</processor>
Basically, the above setting is to have a "localproc" processor and an
"internet" processor which handle locally destined messages and remote
destined ones. The local processor has the RecipientIsLocal matcher to see
whether the messages are indeed locally destined (make sure that the
elements in <servernames> block (in <James> block) represent the local
domain(s)).
The "internet" processor has a SenderHostIsNot matcher, which sees whether
the sender is not from your domain; meaning, messages that sent via your
James and not from the local domain will be stored in the repository; in
which you could check them out later from which IP numbers the messages
were sent out. This would restrict your James to deliver (out) the
messages that originate from your domain only. The originating IP numbers
(network numbers) have been filtered by the RemoteAddrNotInNetwork
matcher, and the sender domain is by the above matcher. I think, ideally
the matcher should be SenderIsLocal (so it does check whether the users are
from your domain).
Oki
ps: matchers in the following (feel free to change the package names):
package com.pindad.james.transport.matchers;
/**
* SenderHostIs.java
*
*
* Created: Wed Aug 29 16:12:59 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Oki DZ</a>
* @version
*/
import java.util.*;
import org.apache.mailet.*;
import org.apache.james.transport.matchers.*;
public class SenderHostIs extends GenericMatcher {
protected Collection senderHosts;
public void init() {
StringTokenizer tokenizer = new StringTokenizer(getCondition(), ",
",false);
senderHosts = new Vector();
while (tokenizer.hasMoreTokens()) {
senderHosts.add(tokenizer.nextToken());
}
}
public Collection match(Mail mail) {
if (senderHosts.contains(mail.getSender().getHost())) {
return mail.getRecipients();
} else {
return null;
}
}
}
package com.pindad.james.transport.matchers;
/**
* SenderHostIsNot.java
*
*
* Created: Wed Aug 29 16:31:04 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">Oki DZ</a>
* @version
*/
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import org.apache.mailet.*;
import org.apache.james.transport.matchers.*;
public class SenderHostIsNot extends SenderHostIs {
public Collection match(Mail mail) { // Fixme: use regex
MailAddress sender = mail.getSender();
if (sender == null) return null;
if (senderHosts.contains(sender.getHost())) {
return null;
} else {
return mail.getRecipients();
}
}
public String getMailetInfo() {
return "SenderHostIsNot";
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]