com.goldeninnovations.smp.messagefilter
Class DomainMessageFilter

java.lang.Object
  extended by com.goldeninnovations.smp.messagefilter.DefaultMessageFilter
      extended by com.goldeninnovations.smp.messagefilter.DomainMessageFilter
All Implemented Interfaces:
MessageFilter

public class DomainMessageFilter
extends DefaultMessageFilter

Accepts all valid email addresses to one of the specified domains.


Constructor Summary
DomainMessageFilter(String... domains)
           
 
Method Summary
 boolean acceptMessage(EmailAddress recipient, InetAddress senderAddress, EmailAddress sender)
          Returns true if the domain name of the recipient matches exactly with one of the domains specified in by the addDomain method (or constructor).
 void addDomain(String domain)
          Add any non-null domain to the accepted list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainMessageFilter

public DomainMessageFilter(String... domains)
Method Detail

addDomain

public void addDomain(String domain)
Add any non-null domain to the accepted list.

Parameters:
domain - a domain name (example.com) to accept emails for.
Throws:
IllegalArgumentException - thrown if the specified domain is null.

acceptMessage

public boolean acceptMessage(EmailAddress recipient,
                             InetAddress senderAddress,
                             EmailAddress sender)
Returns true if the domain name of the recipient matches exactly with one of the domains specified in by the addDomain method (or constructor).

Specified by:
acceptMessage in interface MessageFilter
Overrides:
acceptMessage in class DefaultMessageFilter
Parameters:
recipient - the recipient to test. The email address specified in the RCPT TO command.
senderAddress - the Internet Address of the SMTP client.
sender - The email address specified in the MAIL FROM command.
Returns:
true if the message should be accepted, false otherwise.


Copyright © 2010 Eric Daugherty. All Rights Reserved.