@Deprecated public class JDBCRecipientRewriteTable extends AbstractRecipientRewriteTable
Implements a Virtual User Table for JAMES. Derived from the JDBCAlias mailet, but whereas that mailet uses a simple map from a source address to a destination address, this handles simple wildcard selection, verifies that a catchall address is for a domain in the Virtual User Table, and handles forwarding.
JDBCRecipientRewriteTable does not provide any administation tools. You'll have to create the RecipientRewriteTable yourself. The standard configuration is as follows:
CREATE TABLE RecipientRewriteTable ( user varchar(64) NOT NULL default '', domain varchar(255) NOT NULL default '', target_address varchar(255) NOT NULL default '', PRIMARY KEY (user,domain) );
The user column specifies the username of the virtual recipient, the domain column the domain of the virtual recipient, and the target_address column the email address of the real recipient. The target_address column can contain just the username in the case of a local user, and multiple recipients can be specified in a list separated by commas, semi-colons or colons.
The standard query used with RecipientRewriteTable is:
select RecipientRewriteTable.target_address from RecipientRewriteTable, RecipientRewriteTable as VUTDomains where (RecipientRewriteTable.user like ? or RecipientRewriteTable.user like "\%") and (RecipientRewriteTable.domain like ? or (RecipientRewriteTable.domain like "\%" and VUTDomains.domain like ?)) order by concat(RecipientRewriteTable.user,'@',RecipientRewriteTable.domain) desc limit 1
For a given [user, domain, domain] used with the query, this will match as follows (in precedence order):
You need to set the connection. At the moment, there is a limit to what you can change regarding the SQL Query, because there isn't a means to specify where in the query to replace parameters. [TODO]
<mailet match="All" class="JDBCRecipientRewriteTable"> <table>db://maildb/RecipientRewriteTable</table> <sqlquery>sqlquery</sqlquery> </mailet>
Modifier and Type | Field and Description |
---|---|
protected DataSource |
datasource
Deprecated.
|
protected String |
query
Deprecated.
The query used by the mailet to get the alias mapping
|
Constructor and Description |
---|
JDBCRecipientRewriteTable()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
String |
getMailetInfo()
Deprecated.
|
void |
init()
Deprecated.
Initialize the mailet
|
protected void |
mapRecipients(Map<org.apache.mailet.MailAddress,String> recipientsMap)
Deprecated.
Map any virtual recipients to real recipients using the configured JDBC
connection, table and query.
|
void |
setDataSourceSelector(DataSource datasource)
Deprecated.
|
service, setDNSService, setDomainList
protected DataSource datasource
protected String query
public void setDataSourceSelector(DataSource datasource)
public void init() throws javax.mail.MessagingException
init
in class org.apache.mailet.base.GenericMailet
javax.mail.MessagingException
protected void mapRecipients(Map<org.apache.mailet.MailAddress,String> recipientsMap) throws javax.mail.MessagingException
mapRecipients
in class AbstractRecipientRewriteTable
recipientsMap
- the mapping of virtual to real recipientsjavax.mail.MessagingException
public String getMailetInfo()
getMailetInfo
in interface org.apache.mailet.Mailet
getMailetInfo
in class org.apache.mailet.base.GenericMailet
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.