org.apache.james.transport.mailets
Class WhiteListManager

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.WhiteListManager
All Implemented Interfaces:
Mailet, MailetConfig

public class WhiteListManager
extends GenericMailet

Manages for each local user a "white list" of remote addresses whose messages should never be blocked as spam.

The normal behaviour is to check, for a local sender, if a remote recipient is already in the list: if not, it will be automatically inserted. This is under the interpretation that if a local sender X sends a message to a remote recipient Y, then later on if a message is sent by Y to X it should be considered always valid and never blocked; hence Y should be in the white list of X.

Another mode of operations is when a local sender sends a message to whitelistManagerAddress with one of three specific values in the subject, to (i) send back a message displaying a list of the addresses in his own list; (ii) insert some new addresses in his own list; (iii) remove some addresses from his own list. In all this cases the message will be ghosted and the postmaster will reply to the sender.

The sender name is always converted to its primary name (handling aliases).

Sample configuration:


 <mailet match="SMTPAuthSuccessful" class="WhiteListManager">
   <repositoryPath> db://maildb </repositoryPath>
   <!--
     If true automatically inserts the local sender to remote recipients entries in the whitelist (default is false).
   -->
   <automaticInsert>true</automaticInsert>
   <!--
     Set this to an email address of the "whitelist manager" to send commands to (default is null).
   -->
   <whitelistManagerAddress>whitelist.manager@xxx.yyy</whitelistManagerAddress>
   <!--
     Set this to a unique text that you can use (by sending a message to the "whitelist manager" above)
     to tell the mailet to send back the contents of the white list (default is null).
   -->
   <displayFlag>display whitelist</displayFlag>
   <!--
     Set this to a unique text that you can use (by sending a message to the "whitelist manager" above)
     to tell the mailet to insert some new remote recipients to the white list (default is null).
   -->
   <insertFlag>insert whitelist</insertFlag>
   <!--
     Set this to a unique text that you can use (by sending a message to the "whitelist manager" above)
     to tell the mailet to remove some remote recipients from the white list (default is null).
   -->
   <removeFlag>remove whitelist</removeFlag>
 </mailet>
 

Since:
2.3.0
Version:
SVN $Revision: $ $Date: $
See Also:
IsInWhiteList

Constructor Summary
WhiteListManager()
           
 
Method Summary
 java.lang.String getMailetInfo()
          Returns a string describing this mailet.
 void init()
          Initializes the mailet.
 void initSqlQueries(java.sql.Connection conn, MailetContext mailetContext)
          Initializes the sql query environment from the SqlResources file.
 void service(Mail mail)
          Services the mailet.
 
Methods inherited from class org.apache.mailet.GenericMailet
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WhiteListManager

public WhiteListManager()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Initializes the mailet.

Overrides:
init in class GenericMailet
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the mailet's normal operation

service

public void service(Mail mail)
             throws javax.mail.MessagingException
Services the mailet.

Specified by:
service in interface Mailet
Specified by:
service in class GenericMailet
Parameters:
mail - - the Mail object that contains the MimeMessage and routing information
Throws:
javax.mail.MessagingException - - if an exception occurs that interferes with the mailet's normal operation

getMailetInfo

public java.lang.String getMailetInfo()
Returns a string describing this mailet.

Specified by:
getMailetInfo in interface Mailet
Overrides:
getMailetInfo in class GenericMailet
Returns:
a string describing this mailet

initSqlQueries

public void initSqlQueries(java.sql.Connection conn,
                           MailetContext mailetContext)
                    throws java.lang.Exception
Initializes the sql query environment from the SqlResources file. Will look for conf/sqlResources.xml.

Parameters:
conn - The connection for accessing the database
mailetContext - The current mailet context, for finding the conf/sqlResources.xml file
Throws:
java.lang.Exception - If any error occurs


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.