FileDocCategorySizeDatePackage
SenderHostIs.javaAPI DocApache James 2.3.12906Fri Jan 12 12:56:32 GMT 2007org.apache.james.transport.matchers

SenderHostIs

public class SenderHostIs extends org.apache.mailet.GenericMatcher
Checkes the sender's displayed domain name against a supplied list. Sample configuration: spam
version
1.0.0, 2002-09-10

Fields Summary
private Collection
senderHosts
The collection of host names to match against.
Constructors Summary
Methods Summary
public voidinit()
Initialize the mailet.

        //Parse the condition...
        StringTokenizer st = new StringTokenizer(getCondition(), ", ", false);

        //..into a vector of domain names.
        senderHosts = new java.util.HashSet();
        while (st.hasMoreTokens()) {
            senderHosts.add(st.nextToken().toLowerCase(Locale.US));
        }
        senderHosts = Collections.unmodifiableCollection(senderHosts);
    
public java.util.Collectionmatch(org.apache.mailet.Mail mail)
Takes the message and checks the sender (if there is one) against the vector of host names. Returns the collection of recipients if there's a match.

param
mail the mail being processed

        try {
            if (mail.getSender() != null && senderHosts.contains(mail.getSender().getHost().toLowerCase(Locale.US))) {
                return mail.getRecipients();
            }
        } catch (Exception e) {
            log(e.getMessage());
        }

        return null;    //No match.