Mailets and Matchers Reference

Items marked as Experimental are not yet supported by James; however, you can try them.

Matchers

AbstractNetworkMatcher

AbstractNetworkMatcher makes writing IP Address matchers easier.

This class extends the GenericMatcher, and as such, has access to the matcher condition via GenericMatcher.getCondition().
On initialization, the init method retrieves the condition from the defined matcher and create a corresponding NetMatcher.
The marcher condition has to respect the syntax waited by the NetMacher.

This abstract network matcher needs to be implemented by a concrete class.
The implementing concrete class will call the matchNetwork method.

AbstractQuotaMatcher (Experimental)

Abstract matcher checking whether a recipient has exceeded a maximum allowed quota.

"Quota" at this level is an abstraction whose specific interpretation will be done by subclasses.

Although extending GenericMatcher, its logic is recipient oriented.

AbstractSQLWhitelistMatcher (Experimental)

No documentation is available for this deprecated, experimental matcher.

AbstractStorageQuota (Experimental)

Experimental: Abstract matcher checking whether a recipient has exceeded a maximum allowed storage quota for messages standing in his inbox.

"Storage quota" at this level is still an abstraction whose specific interpretation will be done by subclasses (e.g. could be specific for each user or common to all of them).

This matcher need to calculate the mailbox size every time it is called. This can slow down things if there are many mails in the mailbox. Some users also report big problems with the matcher if a JDBC based mailrepository is used.

All

Matches all mail.

And

This matcher performs And conjunction between the two recipients

AnotherMatcher

Matcher introduced for testing purposes. Rejects all recipients.

AttachmentFileNameIs (Experimental)

Checks if at least one attachment has a file name which matches any element of a comma-separated or space-separated list of file name masks.

Syntax: match="AttachmentFileNameIs=[-d] [-z] masks"

The match is case insensitive.

File name masks may start with a wildcard '*'.

Multiple file name masks can be specified, e.g.: '*.scr,*.bat'.

If '-d' is coded, some debug info will be logged.

If '-z' is coded, the check will be non-recursively applied to the contents of any attached '*.zip' file.

CommandForListserv (Experimental)

Returns positive if the recipient is a command for a listserv. For example, if my listserv is james@list.working-dogs.com, this matcher will return true for james-on@list.working-dogs.com and james-off@list.working-dogs.com.

CommandListservMatcher (Experimental)

CommandListservMatcher is the matcher that pairs with the CommandListservManager It checks to see if the request is intended for the ListservManager, but doesn't guarantee that it is a valid command.
To configure, insert this into the config.xml inside of the root processor block.

<mailet match="CommandListservMatcher=announce@localhost" class="CommandListservManager">
...
</mailet>

CompareNumericHeaderValue (Experimental)

Matches mails containing a header with a numeric value whose comparison with the specified value is true. If the header is missing in the message, there will be no match

Configuration string: The headerName, a comparison operator and the numeric headerValue to compare with, space or tab delimited.

The comparison operators are: <, <=, ==, >=, >; another set of operators is: LT, LE, EQ, GE, GT. Also the following operators are accepted: =<, =, =>.

Example:


   <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability > 0.9" class="ToProcessor">
      <processor> spam </processor>
   </mailet>

CompositeMatcher

A CompositeMatcher contains child matchers that are invoked in turn and their recipient results are composed from the composite operation. See And, Or, Xor and Not. One or more children may be supplied to a composite via declaration inside a processor in the james-config.xml file. When the composite is the outter-most declaration it must be named, as in the example below. The composite matcher may be referenced by name and used in a subsequent mailet. Any matcher may be included as a child of a composite matcher, including another composite matcher or the Not matcher. As a consequence, the class names: And, Or, Not and Xor are permanently reserved.

  <matcher name="a-composite" match="Or">
     <matcher match="And">
         <matcher match="Not">
             <matcher match="HostIs=65.55.116.84"/>
         </matcher>
         <matcher match="HasHeaderWithRegex=X-Verify-SMTP,Host(.*)sending to us was not listening"/>
     </matcher>
     <matchwe match="HasHeaderWithRegex=X-DNS-Paranoid,(.*)"/>
  </matcher>
  
  <mailet match="a-composite" class="ToProcessor">
      <processor>spam</processor>
  </mailet>
*

CustomMatcher

Matcher introduced for testing purposes. Rejects all recipients.

FetchedFrom

Matches mail with a header set by Fetchpop X-fetched-from
fetchpop sets X-fetched-by to the "name" of the fetchpop fetch task.
This is used to match all mail fetched from a specific pop account. Once the condition is met the header is stripped from the message to prevent looping if the mail is re-inserted into the spool. $Id$

FileRegexMatcher (Experimental)

Initializes RegexMatcher with regular expressions from a file.

GenericCompositeMatcher

Abstract base class for CompositeMatchers. This class handles the child collection of Matchers associated with the CompositeMatcher.

GenericMatcher

GenericMatcher implements the Matcher and MatcherConfig interfaces.

GenericMatcher makes writing matchers easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the MatcherConfig interface. GenericMatcher also implements the log method, declared in the MatcherContext interface.

To write a generic matcher, you need only override the abstract match method.

GenericRecipientMatcher

GenericMatcher makes writing recipient based matchers easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the MatcherConfig interface. GenericMatcher also implements the log method, declared in the MatcherContext interface.

GenericRegexMatcher

This is a generic matcher that uses regular expressions. If any of the regular expressions match, the matcher is considered to have matched. This is an abstract class that must be subclassed to feed patterns. Patterns are provided by calling the compile method. A subclass will generally call compile() once during init(), but it could subclass match(), and call it as necessary during message processing (e.g., if a file of expressions changed).

HasAttachment

Checks whether this message has an attachment

HasHabeasWarrantMark (Experimental)

Matcher Info: Habeas Warrant Mark Matcher (see http://www.habeas.com for details).

This matcher tests for the Hebeas Warrant Mark. For details see: http://www.hebeas.com

Usage: Place this matcher


<mailet match="HasHabeasWarrantMark" class="ToProcessor">
    <processor> transport </processor>
</mailet>

in the root processs before the DNSRBL block lists (the InSpammerBlacklist matcher).

Because the Habeas Warrant Mark is copyright material, I have asked for and received the following explicit statement from Habeas:

-----------------------------------
From: Lindsey Pettit [mailto:support@habeas.com]
Sent: Sunday, September 29, 2002 5:51
To: Noel J. Bergman
Subject: RE: Habeas and Apache James

Dear Noel,

> I guess that since your Warrant Mark is copyright, I should ask for
> something from you to explicitly authorize that Hebeas will permit
> this code to be included and distributed as part of Apache James
> under the Apache Software License.  As we have established, the use
> of the Habeas Warrant Mark for filtering is not restricted, but I
> would like something to confirm that, so that Apache will be happy.

I can hereby confirm to you that there is no license necessary in 
order to use the Habeas mark for filtering.  That said, however, we 
do insist that it not ever be used as a basis for rejecting email which 
bears the Habeas mark.
-----------------------------------

HasHeader

use:

<mailet match="HasHeader={<header>[=value]}+" class="..." />

This matcher checks if the header named is present. If complements the AddHeader mailet.

HasMailAttribute

Matcher Info: Has Mail Attribute Matcher

This Matcher determines if the mail contains the attribute specified in the condition, and returns all recipients if it is the case.

Sample configuration:


<mailet match="HasMailAttribute=whatever" class="<any-class>">

HasMailAttributeWithValue

Matcher Info: Has Mail Attribute With Value Matcher

This Matcher determines if the mail contains the attribute specified in the condition and if the value answered when the method toString() is invoked on the attribute is equal to the String value specified in the condition. If both tests are true, all recipients are returned, else null.

Notes:

The current matcher implementation expects a single String value to match on. This matcher requires two values, the attribute name and attribute value. This requires some implicit rules to govern how the single value supplied to the matcher is parsed into two values.

  • In the match condition, the split between the attribute name and the attribute value is made at the first comma. Attribute names that include a comma will parse incorrectly and therefore are not supported by this matcher.
  • Leading and trailing spaces are removed from both the attribute name and attribute value specified in the condition and the tested attribute value in the mail prior to matching. Therefore, "abc" , " abc", "abc " and " abc " are considered equivalent.
  • To test for an empty string, do not specify an attribute value after the comma.

Sample configuration:


<mailet match="HasMailAttributeWithValue=name, value" class="<any-class>">

HasMailAttributeWithValueRegex

Matcher Info: Has Mail Attribute Value Matcher

This Matcher determines if the mail contains the attribute specified in the condition and that attribute matches the supplied regular expression, it returns all recipients if that is the case.

Sample configuration:


<mailet match="HasMailAttributeWithValueRegex=whatever," class="<any-class>">
Note: as it is not possible to put arbitrary objects in the configuration, toString() is called on the attribute value, and that is the value matched against.

HostIs

Matches mail to given hosts.

HostIsLocal

Matches mail to Domains which are local .

InSpammerBlacklist (Experimental)

Checks the network IP address of the sending server against a blacklist of spammers. There are 3 lists that support this...

  • blackholes.mail-abuse.org: Rejected - see http://www.mail-abuse.org/rbl/
  • dialups.mail-abuse.org: Dialup - see http://www.mail-abuse.org/dul/
  • relays.mail-abuse.org: Open spam relay - see http://www.mail-abuse.org/rss/
Example:
<mailet match="InSpammerBlacklist=blackholes.mail-abuse.org." class="ToProcessor">
  <processor>spam</processor>
</mailet>

IsInWhiteList (Experimental)

Matches recipients having the mail sender in the recipient's private whitelist .

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

Configuration string: The database name containing the white list table.

Example:

 <mailet match="IsInWhiteList=db://maildb" class="ToProcessor">
    <processor> transport </processor>
 </mailet>

IsOverQuota

This matcher will check if the incoming email will make recipients exceed their quotas. Quota are managed directly by the mailbox. Performance will depend on your implementation (Cassandra and JPA maintains counts, thus it is a fast operation). Here is a configuration example:


<mailet match="IsOverQuota" class="<any-class>"/>
Read the CLI documentation on how to configure quota. Note: managing quotas can also be done through WebAdmin.

IsSMIMEEncrypted

Checks if a mail is smime encrypted.

IsSMIMESigned

checks if a mail is smime signed.

IsSingleRecipient

Matches mail where the number of recipiants is exactly one.

IsX509CertificateSubject

Checks if the subject of a X509Certificate contains the supplied string. The certificate is read from the specified mail attribute.

If the specified attribute contains more than one certificate the matcher matches if at least one of the certificates contains the given string.

Configuration string:

  • mailAttribute;string

MailboxQuotaFixed (Experimental)

Matcher which can be used to set a quota for users Mailbox. This {@link Matcher} need to recalculate the used space of users mailbox on every call. So use it with caution!

MatcherInverter

This class can be used as a wrapper for getting the "not matched" recipients

NESSpamCheck (Experimental)

This is based on a sample filter.cfg for a Netscape Mail Server to stop spam.

NetworkIsInWhitelist (Experimental)

Matcher which lookup whitelisted networks in a database. The networks can be specified via netmask.

For example: 192.168.0.0/24

Th whitelisting is done per recipient

Not

This is the Not CompositeMatcher - consider what wasn't in the result set of each child matcher. Of course it is easier to understand if it only includes one matcher in the composition, the normal recommended use. @See CompositeMatcher interface.

Or

This is the Or CompositeMatcher - consider it to be a union of the results.

RecipientIs

This matcher matches a specific recipient (in the envelope of the mail), passed as a condition to this matcher.

The example below will match only the recipient user@domain


<mailet match="RecipientIs=user@domain" class="<any-class>">
</mailet>

RecipientIsLocal

Matches mail where the recipient is local.

RecipientIsRegex

Matches recipients whose address matches a regular expression.

Is equivalent to the {@link SenderIsRegex} matcher but matching on the recipient.

Configuration string: a regular expression.


<mailet match="RecipientIsRegex=<regular-expression>" class="<any-class>">

The example below will match any recipient in the format user@log.anything


<mailet match="RecipientIsRegex=(.*)@log\.(.*)" class="<any-class>">
</mailet>

RelayLimit

Matches mail which has been relayed more than a given number of times.

RemoteAddrInNetwork

Checks the IP address of the sending server against a comma- delimited list of IP addresses, domain names or sub-nets.

See AbstractNetworkMatcher for details on how to specify entries.

RemoteAddrNotInNetwork

Checks the IP address of the sending server against a comma- delimited list of IP addresses, domain names or sub-nets.

See AbstractNetworkMatcher for details on how to specify entries.

SMTPAuthSuccessful

Matches mails that are sent by an SMTP authenticated user.

If the sender was not authenticated it will not match.


<mailet match="SMTPAuthSuccessful" class="<any-class>">

SMTPAuthUserIs

Matches mails that are sent by an SMTP authenticated user present in a supplied list.

If the sender was not authenticated it will not match.

Configuration string: a comma, tab or space separated list of James users.


<mailet match="SMTPAuthUserIs=<list-of-user-names>" class="<any-class>">

SMTPIsAuthNetwork (Experimental)

Matches mails that are sent by an client which is allowed to relay.

 <mailet match="SMTPIsAuthNetwork"
class="<any-class>"> 

SenderHostIs

Checkes the sender's displayed domain name against a supplied list.

Sample configuration:


<mailet match="SenderHostIs=domain.com" class="ToProcessor">
  <processor> spam </processor>
</mailet>

SenderHostIsLocal

Checks the sender's displayed domain name against a the hosts serviced by this mail context.

Sample Configuration:

<mailet match="SenderHostIsLocal" class="SpamAssassin"> </mailet>

SenderInFakeDomain (Experimental)

Does a DNS lookup (MX and A/CNAME records) on the sender's domain. If there are no entries, the domain is considered fake and the match is successful.

SenderIs

This matcher matches a specific sender, passed as a condition to this matcher.

The example below will match mail with a sender being user@domain


<mailet match="SenderIs=user@domain" class="<any-class>">
</mailet>

SenderIsLocal

Matches mail where the sender is local.

SenderIsNull

Matches mails that are sent by a null sender.


<mailet match="SenderIsNull" class="<any-class>">

SenderIsRegex

Matches mails that are sent by a sender whose address matches a regular expression.

Is equivalent to the {@link RecipientIsRegex} matcher but matching on the sender.

Configuration string: a regular expression.


<mailet match="SenderIsRegex=<regular-expression>" class="<any-class>">

The example below will match any sender in the format user@log.anything


<mailet match="SenderIsRegex=(.*)@log\.(.*)" class="<any-class>">
</mailet>

Another example below will match any sender having some variations of the string mp3 inside the username part.


<mailet match="SenderIsRegex=(.*)(mp3|emmepitre)(.*)@" class="<any-class>">
</mailet>

SentByMailet

This matcher matches email sent automatically by mailets.


<mailet match="SentByMailetAny" class="<any-class>"/>
This matcher allows you, for instance, to enable/disable routing automatically generated emails out of your server.

SizeGreaterThan

Checks whether the message (entire message, not just content) is greater than a certain number of bytes. You can use 'k' and 'm' as optional postfixes. In other words, "1m" is the same as writing "1024k", which is the same as "1048576".

SubjectIs

Matches mail where the subject is contained in a configurable list.

SubjectStartsWith

Matches mail where the subject starts with a given phrase.

TooManyLines

This matcher matches emails that have too many lines. This allows better rejection of emails when, for instance, MIME4J is configured with a limited number of lines.

The example below will match mail with more than 10000 lines


<mailet match="TooManyLines=10000" class="<any-class>"/>

TooManyRecipients

This matcher matches emails that have too many recipients.

The example below will reject any email with more than 5 recipients


<mailet match="TooManyRecipients=5" class="<any-class>"/>

UserIs

Matches mail where the user is contained in a configurable list.

Xor

This is the Xor CompositeMatcher - consider it to be the inequality operator for recipients. If any recipients match other matcher results then the result does not include that recipient.

Mailets

AbstractRecipientRewriteTable (Experimental)

Provides an abstraction of common functionality needed for implementing a Virtual User Table. Override the mapRecipients method to map virtual recipients to real recipients.

AbstractSign

Abstract mailet providing common SMIME signature services. It can be subclassed to make authoring signing mailets simple. By extending it and overriding one or more of the following methods a new behaviour can be quickly created without the author having to address any issue other than the relevant one:

  • {@link #initDebug}, {@link #setDebug} and {@link #isDebug} manage the debugging mode.
  • {@link #initExplanationText}, {@link #setExplanationText} and {@link #getExplanationText} manage the text of an attachment that will be added to explain the meaning of this server-side signature.
  • {@link #initKeyHolder}, {@link #setKeyHolder} and {@link #getKeyHolder} manage the {@link KeyHolder} object that will contain the keys and certificates and will do the crypto work.
  • {@link #initPostmasterSigns}, {@link #setPostmasterSigns} and {@link #isPostmasterSigns} determines whether messages originated by the Postmaster will be signed or not.
  • {@link #initRebuildFrom}, {@link #setRebuildFrom} and {@link #isRebuildFrom} determines whether the "From:" header will be rebuilt to neutralize the wrong behaviour of some MUAs like Microsoft Outlook Express.
  • {@link #initSignerName}, {@link #setSignerName} and {@link #getSignerName} manage the name of the signer to be shown in the explanation text.
  • {@link #isOkToSign} controls whether the mail can be signed or not.
  • The abstract method {@link #getWrapperBodyPart} returns the massaged {@link javax.mail.internet.MimeBodyPart} that will be signed, or null if the message has to be signed "as is".

Handles the following init parameters:

  • <keyHolderClass>: Sets the class of the KeyHolder object that will handle the cryptography functions, for example org.apache.james.security.SMIMEKeyHolder for SMIME.
  • <debug>: if true some useful information is logged. The default is false.
  • <keyStoreFileName>: the {@link java.security.KeyStore} full file name.
  • <keyStorePassword>: the KeyStore password. If given, it is used to check the integrity of the keystore data, otherwise, if null, the integrity of the keystore is not checked.
  • <keyAlias>: the alias name to use to search the Key using {@link java.security.KeyStore#getKey}. The default is to look for the first and only alias in the keystore; if zero or more than one is found a {@link java.security.KeyStoreException} is thrown.
  • <keyAliasPassword>: the alias password. The default is to use the KeyStore password. At least one of the passwords must be provided.
  • <keyStoreType>: the type of the keystore. The default will use {@link java.security.KeyStore#getDefaultType}.
  • <postmasterSigns>: if true the message will be signed even if the sender is the Postmaster. The default is false.
  • <rebuildFrom>: If true will modify the "From:" header. For more info see {@link #isRebuildFrom}. The default is false.
  • <signerName>: the name of the signer to be shown in the explanation text. The default is to use the "CN=" property of the signing certificate.
  • <explanationText>: the text of an explanation of the meaning of this server-side signature. May contain the following substitution patterns (see also {@link #getReplacedExplanationText}): [signerName], [signerAddress], [reversePath], [headers]. It should be included in the signature. The actual presentation of the text depends on the specific concrete mailet subclass: see for example {@link SMIMESign}. The default is to not have any explanation text.

AddDeliveredToHeader

This mailet adds the de-facto standard QMail Delivered-To header. Upon processing by LocalDelivery, a Delivered-To header matching the recipient mail address will be added before storage.


<mailet match="All" class="<AddDeliveredToHeader>"/>

AddFooter

Mailet Info: AddFooter Mailet

Takes the message and attaches a footer message to it. Right now, it only supports simple messages. Needs to have additions to make it support messages with alternate content types or with attachments.

AddHabeasWarrantMark (Experimental)

Mailet Info: Add Habeas Warrant Mark. Must be used in accordance with a license from Habeas (see http://www.habeas.com for details).

This matcher adds the Hebeas Warrant Mark to a message. For details see: http://www.hebeas.com

Usage:


<mailet match="<suitable-matcher>" class="AddHabeasWarrantMark" />

NOTE: Although this mailet is covered by the Apache Software License, the Habeas Warrant Mark is copyright. A separate license from Habeas is required in order to legally attach the Habeas Warrant Mark to e-mail messages. Each James Administrator is responsible for ensuring that James is configured to attach the Habeas Warrant Mark only to e-mail covered by a suitable license received from Habeas. Because the Habeas Warrant Mark is copyright material, I have asked for and received the following explicit statement from Habeas:

-----------------------------------
From: Lindsey Pettit [mailto:support@habeas.com]
Sent: Sunday, September 29, 2002 5:51
To: Noel J. Bergman
Subject: RE: Habeas and Apache James

Dear Noel,

> FURTHERMORE, if James is to be capable of sending Habeas SWE, I need
> to write a Mailet that attaches the headers.  As with any MTA, it
> would be up to the administrator to properly configure James and make
> sure that licenses are acquired.  Since the Habeas Warrant Mark is
> copyright, I believe that I require authorization from you for that
> Mailet, especially since it attaches the Habeas Warrant Mark.  For my
> own protection, please show me why such authorization is unnecessary,
> send me a digitally signed e-mail, or FAX a signed authorization

You do not yourself need the authorization to build the functionality 
into the [mailet];  what one needs authorization, in the form of a 
license, for, is to use the mark *in headers*, in outgoing email.
However, please let me know if you would like something more 
formal, and I can try to have something faxed to you.

> The Mailet docs would reference the Habeas website, and inform
> administrators that in order to USE the mailet, they need to ensure
> that they have whatever licenses are required from you as appropriate
> to your licensing terms.

That's absolutely perfect!
-----------------------------------

AddSubjectPrefix

Mailet Info: AddSubjectPrefix Mailet

Add an prefix (tag) to the subject of a message

Sample Configuration:


<mailet match="RecipientIs=robot@james.apache.org" class="TagMessage">
<subjectPrefix>[robot]</subjectPrefix> </mailet> 

AmqpForwardAttribute

Mailet Info: AmqpForwardAttribute

This mailet forwards the attributes values to a AMPQ.
It takes 4 parameters:

  • attribute (mandatory): content to be forwarded, expected to be a Map<String, byte[]> where the byte[] content is issued from a MimeBodyPart. It is typically generated from the StripAttachment mailet.
  • uri (mandatory): AMQP URI defining the server where to send the attachment.
  • exchange (mandatory): name of the AMQP exchange.
  • routing_key (optional, default to empty string): name of the routing key on this exchange.
This mailet will extract the attachment content from the MimeBodyPart byte[] before sending it.

AnotherMailet

Mailet introduced for testing purposes. Does nothing.

BayesianAnalysis (Experimental)

Mailet Info: BayesianAnalysis Mailet

Spam detection mailet using bayesian analysis techniques.

Sets an email message header indicating the probability that an email message is SPAM.

Based upon the principals described in: A Plan For Spam by Paul Graham. Extended to Paul Grahams' Better Bayesian Filtering.

The analysis capabilities are based on token frequencies (the Corpus) learned through a training process (see {@link BayesianAnalysisFeeder}) and stored in a JDBC database. After a training session, the Corpus must be rebuilt from the database in order to acquire the new frequencies. Every 10 minutes a special thread in this mailet will check if any change was made to the database by the feeder, and rebuild the corpus if necessary.

A org.apache.james.spam.probability mail attribute will be created containing the computed spam probability as a {@link java.lang.Double}. The headerName message header string will be created containing such probability in floating point representation.

Sample configuration:


<mailet match="All" class="BayesianAnalysis">
  <repositoryPath>db://maildb</repositoryPath>
  <!--
    Set this to the header name to add with the spam probability
    (default is "X-MessageIsSpamProbability").
  -->
  <headerName>X-MessageIsSpamProbability</headerName>
  <!--
    Set this to true if you want to ignore messages coming from local senders
    (default is false).
    By local sender we mean a return-path with a local server part (server listed
    in <servernames> in config.xml).
  -->
  <ignoreLocalSender>true</ignoreLocalSender>
  <!--
    Set this to the maximum message size (in bytes) that a message may have
    to be considered spam (default is 100000).
  -->
  <maxSize>100000</maxSize>
  <!--
    Set this to false if you not want to tag the message if spam is detected (Default is true).
  -->
  <tagSubject>true</tagSubject>
</mailet>

The probability of being spam is pre-pended to the subject if it is > 0.1 (10%).

The required tables are automatically created if not already there (see sqlResources.xml). The token field in both the ham and spam tables is case sensitive.

BayesianAnalysis (Experimental)

Mailet Info: BayesianAnalysis Mailet

Spam detection mailet using bayesian analysis techniques.

Sets an email message header indicating the probability that an email message is SPAM.

Based upon the principals described in: A Plan For Spam by Paul Graham. Extended to Paul Grahams' Better Bayesian Filtering.

The analysis capabilities are based on token frequencies (the Corpus) learned through a training process (see {@link BayesianAnalysisFeeder}) and stored in a JDBC database. After a training session, the Corpus must be rebuilt from the database in order to acquire the new frequencies. Every 10 minutes a special thread in this mailet will check if any change was made to the database by the feeder, and rebuild the corpus if necessary.

A org.apache.james.spam.probability mail attribute will be created containing the computed spam probability as a {@link java.lang.Double}. The headerName message header string will be created containing such probability in floating point representation.

Sample configuration:


<mailet match="All" class="BayesianAnalysis">
  <repositoryPath>db://maildb</repositoryPath>
  <!--
    Set this to the header name to add with the spam probability
    (default is "X-MessageIsSpamProbability").
  -->
  <headerName>X-MessageIsSpamProbability</headerName>
  <!--
    Set this to true if you want to ignore messages coming from local senders
    (default is false).
    By local sender we mean a return-path with a local server part (server listed
    in <servernames> in config.xml).
  -->
  <ignoreLocalSender>true</ignoreLocalSender>
  <!--
    Set this to the maximum message size (in bytes) that a message may have
    to be considered spam (default is 100000).
  -->
  <maxSize>100000</maxSize>
  <!--
    Set this to false if you not want to tag the message if spam is detected (Default is true).
  -->
  <tagSubject>true</tagSubject>
</mailet>

The probability of being spam is pre-pended to the subject if it is > 0.1 (10%).

The required tables are automatically created if not already there (see sqlResources.xml). The token field in both the ham and spam tables is case sensitive.

BayesianAnalysisFeeder (Experimental)

Mailet Info: BayesianAnalysisFeeder Mailet

Feeds ham OR spam messages to train the {@link BayesianAnalysis} mailet.

The new token frequencies will be stored in a JDBC database.

Sample configuration:


<processor name="root">

  <mailet match="RecipientIs=not.spam@thisdomain.com" class="BayesianAnalysisFeeder">
    <repositoryPath> db://maildb </repositoryPath>
    <feedType>ham</feedType>
    <!--
      Set this to the maximum message size (in bytes) that a message may have
      to be analyzed (default is 100000).
    -->
    <maxSize>100000</maxSize>
  </mailet>

  <mailet match="RecipientIs=spam@thisdomain.com" class="BayesianAnalysisFeeder">
    <repositoryPath> db://maildb </repositoryPath>
    <feedType>spam</feedType>
    <!--
      Set this to the maximum message size (in bytes) that a message may have
      to be analyzed (default is 100000).
    -->
    <maxSize>100000</maxSize>
  </mailet>

<processor>

The previous example will allow the user to send messages to the server and use the recipient email address as the indicator for whether the message is ham or spam.

Using the example above, send good messages (ham not spam) to the email address "not.spam@thisdomain.com" to pump good messages into the feeder, and send spam messages (spam not ham) to the email address "spam@thisdomain.com" to pump spam messages into the feeder.

The bayesian database tables will be updated during the training reflecting the new data

At the end the mail will be destroyed (ghosted).

The correct approach is to send the original ham/spam message as an attachment to another message sent to the feeder; all the headers of the enveloping message will be removed and only the original message's tokens will be analyzed.

After a training session, the frequency Corpus used by BayesianAnalysis must be rebuilt from the database, in order to take advantage of the new token frequencies. Every 10 minutes a special thread in the BayesianAnalysis mailet will check if any change was made to the database, and rebuild the corpus if necessary.

Only one message at a time is scanned (the database update activity is synchronized) in order to avoid too much database locking, as thousands of rows may be updated just for one message fed.

BayesianAnalysisFeeder (Experimental)

Mailet Info: BayesianAnalysisFeeder Mailet

Feeds ham OR spam messages to train the {@link BayesianAnalysis} mailet.

The new token frequencies will be stored in a JDBC database.

Sample configuration:


<processor name="root">

  <mailet match="RecipientIs=not.spam@thisdomain.com" class="BayesianAnalysisFeeder">
    <repositoryPath> db://maildb </repositoryPath>
    <feedType>ham</feedType>
    <!--
      Set this to the maximum message size (in bytes) that a message may have
      to be analyzed (default is 100000).
    -->
    <maxSize>100000</maxSize>
  </mailet>

  <mailet match="RecipientIs=spam@thisdomain.com" class="BayesianAnalysisFeeder">
    <repositoryPath> db://maildb </repositoryPath>
    <feedType>spam</feedType>
    <!--
      Set this to the maximum message size (in bytes) that a message may have
      to be analyzed (default is 100000).
    -->
    <maxSize>100000</maxSize>
  </mailet>

<processor>

The previous example will allow the user to send messages to the server and use the recipient email address as the indicator for whether the message is ham or spam.

Using the example above, send good messages (ham not spam) to the email address "not.spam@thisdomain.com" to pump good messages into the feeder, and send spam messages (spam not ham) to the email address "spam@thisdomain.com" to pump spam messages into the feeder.

The bayesian database tables will be updated during the training reflecting the new data

At the end the mail will be destroyed (ghosted).

The correct approach is to send the original ham/spam message as an attachment to another message sent to the feeder; all the headers of the enveloping message will be removed and only the original message's tokens will be analyzed.

After a training session, the frequency Corpus used by BayesianAnalysis must be rebuilt from the database, in order to take advantage of the new token frequencies. Every 10 minutes a special thread in the BayesianAnalysis mailet will check if any change was made to the database, and rebuild the corpus if necessary.

Only one message at a time is scanned (the database update activity is synchronized) in order to avoid too much database locking, as thousands of rows may be updated just for one message fed.

Bounce

Generates a response to the reverse-path address. Note that this is different than a mail-client's reply, which would use the Reply-To or From header.

Bounced messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".
The reverse-path and the Return-Path header of the response is set to "null" ("<>"), meaning that no reply should be sent.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.
A notice text can be specified, and in such case will be inserted into the notification inline text.
If the notified message has an "error message" set, it will be inserted into the notification inline text. If the attachError init parameter is set to true, such error message will be attached to the notification message.

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="Bounce">
  <sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
  <attachError>true or false, default=false</attachError>
  <message>notice attached to the original message text (optional)</message>
  <prefix>optional subject prefix prepended to the original message</prefix>
  <inline>see {@link Resend}, default=none</inline>
  <attachment>see {@link Resend}, default=message</attachment>
  <passThrough>true or false, default=true</passThrough>
  <fakeDomainCheck>true or false, default=true</fakeDomainCheck>
  <debug>true or false, default=false</debug>
</mailet>

The behaviour of this mailet is equivalent to using Resend with the following configuration:


<mailet match="All" class="Resend">
  <sender>an address or postmaster or sender or unaltered</sender>
  <attachError>true or false</attachError>
  <message>dynamically built</message>
  <prefix>a string</prefix>
  <passThrough>true or false</passThrough>
  <fakeDomainCheck>true or false</fakeDomainCheck>
  <recipients>sender</recipients>
  <reversePath>null</reversePath>
  <inline>see {@link Resend}</inline>
  <attachment>see {@link Resend}</attachment>
  <isReply>true</isReply>
  <debug>true or false</debug>
</mailet>

notice and sendingAddress can be used instead of message and sender; such names are kept for backward compatibility.

ClamAVScan (Experimental)

Mailet Info: Antivirus Check using ClamAV (CLAMD)

Does an antivirus scan check using a ClamAV daemon (CLAMD)

Interacts directly with the daemon using the "stream" method, which should have the lowest possible overhead.

The CLAMD daemon will typically reside on localhost, but could reside on a different host. It may also consist on a set of multiple daemons, each residing on a different server and on different IP number. In such case a DNS host name with multiple IP addresses (round-robin load sharing) is supported by the mailet (but on the same port number).

Handles the following init parameters:

  • <debug>.
  • <host>: the host name of the server where CLAMD runs. It can either be a machine name, such as "java.sun.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked. If the machine name resolves to multiple IP addresses, round-robin load sharing will be used. The default is localhost.
  • <port>: the port on which CLAMD listens. The default is 3310.
  • <maxPings>: the maximum number of connection retries during startup. If the value is 0 no startup test will be done. The default is 6.
  • <pingIntervalMilli>: the interval (in milliseconds) between each connection retry during startup. The default is 30000 (30 seconds).
  • <streamBufferSize>: the BufferedOutputStream buffer size to use writing to the stream connection. The default is 8192.

The actions performed are as follows:

  • During initialization:
    1. Gets all config.xml parameters, handling the defaults;
    2. resolves the <host> parameter, creating the round-robin IP list;
    3. connects to CLAMD at the first IP in the round-robin list, on the specified <port>;
    4. if unsuccessful, retries every <pingIntervalMilli> milliseconds up to <maxPings> times;
    5. sends a PING request;
    6. waits for a PONG answer;
    7. repeats steps 3-6 for every other IP resolved.
  • For every mail
    1. connects to CLAMD at the "next" IP in the round-robin list, on the specified <port>, and increments the "next" index; if the connection request is not accepted tries with the next one in the list unless all of them have failed;
    2. sends a "STREAM" request;
    3. parses the "PORT streamPort" answer obtaining the port number;
    4. makes a second connection (the stream connection) to CLAMD at the same host (or IP) on the streamPort just obtained;
    5. sends the mime message to CLAMD (using {@link MimeMessage#writeTo(java.io.OutputStream)}) through the stream connection;
    6. closes the stream connection;
    7. gets the "OK" or "... FOUND" answer from the main connection;
    8. closes the main connection;
    9. sets the "org.apache.james.infected" mail attribute to either "true" or "false";
    10. adds the "X-MessageIsInfected" header to either "true" or "false";

Some notes regarding clamav.conf:

  • LocalSocket must be commented out
  • TCPSocket must be set to a port# (typically 3310)
  • StreamMaxLength must be >= the James config.xml parameter <maxmessagesize> in SMTP <handler>
  • MaxThreads should? be >= the James config.xml parameter <threads> in <spoolmanager>
  • ScanMail must be uncommented

Here follows an example of config.xml definitions deploying CLAMD on localhost, and handling the infected messages:


...

<!-- Do an antivirus scan --> <mailet match="All" class="ClamAVScan" onMailetException="ignore"/>

<!-- If infected go to virus processor --> <mailet match="HasMailAttributeWithValue=org.apache.james.infected, true" class="ToProcessor"> <processor> virus </processor> </mailet>

<!-- Check attachment extensions for possible viruses --> <mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="ToProcessor"> <processor> bad-extensions </processor> </mailet>

...

<!-- Messages containing viruses --> <processor name="virus">

<!-- To avoid a loop while bouncing --> <mailet match="All" class="SetMailAttribute"> <org.apache.james.infected>true, bouncing</org.apache.james.infected> </mailet>

<mailet match="SMTPAuthSuccessful" class="Bounce"> <sender>bounce-admin@xxx.com</sender> <inline>heads</inline> <attachment>none</attachment> <notice> Warning: We were unable to deliver the message below because it was found infected by virus(es). </notice> </mailet>

<!-- <mailet match="All" class="ToRepository"> <repositoryPath>file://var/mail/infected/</repositoryPath> </mailet> -->

<mailet match="All" class="Null" /> </processor>

ClassifyBounce (Experimental)

Mailet Info: SetMimeHeader Mailet

Assesses the message to determine if it was a hard or soft bounce, and if it was a soft bounce, something of its nature..

Sample configuration:

X-MailetHeader

Counter

Mailet Info: Counter Mailet

A simple in memory counter. Designed to count messages sent to this recipient for debugging purposes.

CustomMailet

Mailet introduced for testing purposes. Does nothing.

DSNBounce

Generates a Delivery Status Notification (DSN) Note that this is different than a mail-client's reply, which would use the Reply-To or From header.

Bounced messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".
The reverse-path and the Return-Path header of the response is set to "null" ("<>"), meaning that no reply should be sent.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="DSNBounce">
  <sender>an address or postmaster or sender or unaltered,
 default=postmaster</sender>
  <prefix>optional subject prefix prepended to the original
 message</prefix>
  <attachment>message, heads or none, default=message</attachment>
  <messageString>the message sent in the bounce, the first occurrence of the pattern [machine] is replaced with the name of the executing machine, default=Hi. This is the James mail server at 
[machine] ... </messageString>
  <passThrough>true or false, default=true</passThrough>
  <debug>true or false, default=false</debug>
</mailet>

DumpSystemErr

Mailet Info: Dumps message to System.err

Debugging purpose Mailet. Sends the message to System.err

ExceptionThrowingMailet

Mailet Info: ExceptionThrowingMailet Mailet

Debugging purpose Mailet. Just throws an exception.

Forward

Replaces incoming recipients with those specified, and resends the message unaltered.

Can be totally replaced by an equivalent usage of {@link Resend} (see below), simply replacing <forwardto> with <recipients>.

Sample configuration:


<mailet match="All" class="Forward">
  <forwardTo>comma delimited list of email addresses</forwardTo>
  <passThrough>true or false, default=false</passThrough>
  <fakeDomainCheck>true or false, default=true</fakeDomainCheck>
  <debug>true or false, default=false</debug>
</mailet>

The behaviour of this mailet is equivalent to using Resend with the following configuration:


<mailet match="All" class="Resend">
  <recipients>comma delimited list of email addresses</recipients>
  <passThrough>true or false</passThrough>
  <fakeDomainCheck>true or false</fakeDomainCheck>
  <debug>true or false</debug>
</mailet>

forwardto can be used instead of forwardTo; such name is kept for backward compatibility.

FromRepository (Experimental)

Mailet Info: FromRepository Mailet

Re-spools Mail found in the specified Repository.

<mailet match="RecipientIs=respool@localhost" class="FromRepository">
   <repositoryPath> repository path </repositoryPath>
   <processor> target processor </repositoryPath>
   <delete&t; [true|false] </delete>
</mailet>

GenericMailet

GenericMailet makes writing mailets easier. It provides simple versions of the lifecycle methods init and destroy and of the methods in the MailetConfig interface. GenericMailet also implements the log method, declared in the MailetContext interface.

To write a generic mailet, you need only override the abstract service method.

HeadersToHTTP (Experimental)

Mailet Info: HTTP POST serialised message

Serialise the email and pass it to an HTTP call Sample configuration: http://192.168.0.252:3000/alarm Test ParameterValue true

ICALToHeader

Mailet Info: ICALToHeader Mailet

ICALToHeader takes a Map of filenames to ICAL4J calendars, will pick the first Calendar, and add it to the headers of the e-mail. The following headers will be added : X_MEETING_UID, X_MEETING_METHOD, X_MEETING_RECURRENCE_ID, X_MEETING_SEQUENCE, X_MEETING_DTSTAMP The only configuration parameter for this mailet is the attribute the ICAL4J Calendar map should be attached to, named attribute. Configuration example :

    
        <mailet matcher=??? class=ICALToHeader>
            <attribute>icalendars</attribute>
        </mailet>
    

ICALToJsonAttribute

Mailet Info: ICALToJson Mailet

ICALToJsonAttribute takes a map of ICAL4J objects attached as attribute, and output the map of corresponding json bytes as an other attribute, with unique String keys. The JSON contains the following fields :

  • ical : the raw ical string, in UTF-8
  • sender : the sender of the mail (compulsory, mail without sender will be discarded)
  • recipient : the recipient of the mail. If the mail have several recipients, each recipient will have its own JSON.
  • uid : the UID of the ical (optional)
  • sequence : the sequence of the ical (optional)
  • dtstamp : the date stamp of the ical (optional)
  • method : the method of the ical (optional)
  • recurrence-id : the recurrence-id of the ical (optional)
Example are included in test call ICalToJsonAttributeTest. Configuration example :
    
        <mailet matcher=??? class=ICALToJsonAttribute>
            <sourceAttribute>icalendars</sourceAttribute>
            <destinationAttribute>icalendarJson</destinationAttribute>
        </mailet>
    

ICalendarParser

Mailet Info: Calendar Parser

This mailet can be combined with the Strip attachment mailet.

The ICS body part byte array is arranged as map then this mailet should look for ICS and parse it with Ical4J then store it as a mail attribute

Configuration: The mailet contains 2 mandatory attributes

  <mailet match="All" class="ICalendarParser" >
    <sourceAttribute>source.attribute.name</sourceAttribute>  <!-- The attribute which contains output value of StripAttachment mailet -- >
    <destAttribute>dest.attribute.name</destAttribute>  <!-- The attribute store the map of Calendar -- >
  </mailet >

Identity

Mailet Info: Identity Mailet

Opposite of Null Mailet. It let any incoming mail untouched. Used only for debugging.

JDBCAlias (Experimental)

Mailet Info: JDBC aliasing mailet

Rewrites recipient addresses based on a database table. The connection is configured by passing the URL to a conn definition. You need to set the table name to check (or view) along with the source and target columns to use. For example,

<mailet match="All" class="JDBCAlias">
  <mappings>db://maildb/Aliases</mappings>
  <source_column>source_email_address</source_column>
  <target_column>target_email_address</target_column>
</mailet>

JDBCRecipientRewriteTable (Experimental)

Mailet Info: JDBC Virtual User Table mailet

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):

  1. user@domain - explicit mapping for user@domain
  2. user@% - catchall mapping for user anywhere
  3. %@domain - catchall mapping for anyone at domain
  4. null - no valid mapping

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>

LocalDelivery

Receives a Mail from the Queue and takes care of delivery of the message to local inboxes. This mailet is a composition of RecipientRewriteTable, SieveMailet and MailboxManager configured to mimic the old "LocalDelivery" James 2.3 behavior.

LogMessage

Mailet Info: LogHeaders Mailet

Logs Message Headers and/or Body. If the "passThrough" in confs is true the mail will be left untouched in the pipe. If false will be destroyed. Default is true.

MailAttributesToMimeHeaders

Convert attributes to headers

Sample configuration:


<mailet match="All" class="MailAttributesToMimeHeaders">
<simplemapping>org.apache.james.attribute1;
headerName1</simplemapping>
<simplemapping>org.apache.james.attribute2;
headerName2</simplemapping> </mailet>

ManageSieveMailet (Experimental)

Mailet Info: org.apache.james.transport.mailets.managesieve.ManageSieveMailet

ManageSieveMailet interprets mail from a local sender as commands to manage Sieve scripts stored on the mail server. The commands are a subset of those defined by http://tools.ietf.org/html/rfc5804#section-2 "MessageToCoreToMessage".

For each supported command and associated response, the format is the same as defined by RFC 5804, with the exception that when Sieve scripts are involved in the exchange they are attached to the mail with the MIME type of 'application/sieve' rather than being embedded in the command.

The command is written in the subject header of a mail received by this mailet. Responses from this mailet are sent to the sender as mail with the message body containing the response.

The following commands are supported:

An Important Note About Security

The mail server on which this mailet is deployed MUST robustly authenticate the sender, who MUST be local.

Sieve provides powerful email processing capabilities that if hijacked can expose the mail of individuals and organisations to intruders.

MetricsMailet

This Metrics mailet increments a counter on every incoming emails. This counter is accessible via JMX. Example : <mailet matcher="all" class="MetricsMailet"> <metricName>relayDenied</metricName> </mailet> Will increment a counter relay denied

MimeDecodingMailet

Mailet Info: MimeDecodingMailet

This mailet replace the mail attribute map of key to MimePart by a map of key to the MimePart content (as bytes).
It takes only one parameter:

  • attribute (mandatory): mime content to be decoded, expected to be a Map<String, byte[]>
Then all this map attribute values will be replaced by their content.

NotifyPostmaster

Sends a notification message to the Postmaster.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.
The "To:" header of the notification message can be set to "unaltered"; if missing will be set to the postmaster.
A notice text can be specified, and in such case will be inserted into the notification inline text.
If the notified message has an "error message" set, it will be inserted into the notification inline text. If the attachError init parameter is set to true, such error message will be attached to the notification message.
The notified messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="NotifyPostmaster">
  <sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
  <attachError>true or false, default=false</attachError>
  <message>notice attached to the original message text (optional)</message>
  <prefix>optional subject prefix prepended to the original message, default="Re:"</prefix>
  <inline>see {@link Resend}, default=none</inline>
  <attachment>see {@link Resend}, default=message</attachment>
  <passThrough>true or false, default=true</passThrough>
  <fakeDomainCheck>true or false, default=true</fakeDomainCheck>
  <to>unaltered (optional, defaults to postmaster)</to>
  <debug>true or false, default=false</debug>
</mailet>

The behaviour of this mailet is equivalent to using Resend with the following configuration:


<mailet match="All" class="Resend">
  <sender>an address or postmaster or sender or unaltered</sender>
  <attachError>true or false</attachError>
  <message>dynamically built</message>
  <prefix>a string</prefix>
  <passThrough>true or false</passThrough>
  <fakeDomainCheck>true or false</fakeDomainCheck>
  <to>unaltered or postmaster</to>
  <recipients>postmaster</recipients>
  <inline>see {@link Resend}</inline>
  <attachment>see {@link Resend}</attachment>
  <isReply>true</isReply>
  <debug>true or false</debug>
</mailet>

notice, sendingAddress and attachError can be used instead of message, sender and attachError; such names are kept for backward compatibility.

NotifySender

Sends a notification message to the sender of a message.

A sender of the notification message can optionally be specified. If one is not specified, the postmaster's address will be used.
The "To:" header of the notification message can be set to "unaltered"; if missing will be set to the sender of the notified message.
A notice text can be specified, and in such case will be inserted into the notification inline text.
If the notified message has an "error message" set, it will be inserted into the notification inline text. If the attachError init parameter is set to true, such error message will be attached to the notification message.
The notified messages are attached in their entirety (headers and content) and the resulting MIME part type is "message/rfc822".

Supports the passThrough init parameter (true if missing).

Sample configuration:


<mailet match="All" class="NotifySender">
  <sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
  <attachError>true or false, default=false</attachError>
  <prefix>optional subject prefix prepended to the original message</prefix>
  <inline>see {@link Resend}, default=none</inline>
  <attachment>see {@link Resend}, default=message</attachment>
  <passThrough>true or false, default=true</passThrough>
  <fakeDomainCheck>true or false, default=true</fakeDomainCheck>
  <to>unaltered or sender or from(optional, defaults to sender)</to>
  <debug>true or false, default=false</debug>
</mailet>

The behaviour of this mailet is equivalent to using Resend with the following configuration:


<mailet match="All" class="Resend">
  <sender>an address or postmaster or sender or unaltered</sender>
  <attachError>true or false</attachError>
  <message>dynamically built</message>
  <prefix>a string</prefix>
  <passThrough>true</passThrough>
  <fakeDomainCheck>true or false</fakeDomainCheck>
  <to>unaltered or sender or from<;/to>
  <recipients>sender</recipients>
  <inline>none</inline>
  <attachment>message</attachment>
  <isReply>true</isReply>
  <debug>true or false</debug>
</mailet>

notice, sendingAddress and attachError can be used instead of message, sender and attachError; such names are kept for backward compatibility.

Null

Mailet Info: Null Mailet

Simplest Mailet which destroys any incoming messages by setting their state to GHOST

OnlyText (Experimental)

Mailet Info: OnlyText

Keep only the text part of a message.

If the message is text only then it doesn't touch it, if it is a multipart it transform it a in plain text message with the first text part found.
- text/plain
- text/html => with a conversion to text only
- text/* as is.

PostmasterAlias

Mailet Info: Postmaster aliasing mailet

Rewrites recipient addresses to make sure email for the postmaster is always handled. This mailet is silently inserted at the top of the root spool processor. All recipients mapped to postmaster@ are changed to the postmaster account as specified in the server conf.

RecipientRewriteTable

Mailet which should get used when using RecipientRewriteTable-Store to implementations for mappings of forwards and aliases.

RecipientToLowerCase

{@link GenericMailet} which convert all Recipients to lowercase

RecoverAttachment (Experimental)

Mailet Info: RecoverAttachment Mailet

This mailet takes an attachment stored in an attribute and attach it back to the message

This may be used to place back attachment stripped by StripAttachment and stored in the attribute org.apache.james.mailet.standard.mailets.StripAttachment.saved

  <mailet match="All" class="RecoverAttachment" >
    <attribute>my.attribute.name</attribute>
  </mailet >

Redirect

A mailet providing configurable redirection services.

Can produce listserver, forward and notify behaviour, with the original message intact, attached, appended or left out altogether.

It differs from {@link Resend} because (i) some defaults are different, notably for the following parameters: <recipients>, <to>, <reversePath> and <inline>; (ii) because it allows the use of the <static> parameter;.
Use Resend if you need full control, Redirect if the more automatic behaviour of some parameters is appropriate.

This built in functionality is controlled by the configuration as laid out below. In the table please note that the parameters controlling message headers accept the "unaltered" value, whose meaning is to keep the associated header unchanged and, unless stated differently, corresponds to the assumed default if the parameter is missing.

The configuration parameters are:

<recipients> A comma delimited list of addresses for recipients of this message; it will use the "to" list if not specified, and "unaltered" if none of the lists is specified.
These addresses will only appear in the To: header if no "to" list is supplied.
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "from" is made equivalent to "sender", and "to" is made equivalent to "recipients"; "null" is ignored.
<to> A comma delimited list of addresses to appear in the To: header; the email will be delivered to any of these addresses if it is also in the recipients list.
The recipients list will be used if this list is not supplied; if none of the lists is specified it will be "unaltered".
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "from" uses the From header if available, otherwise the Sender header if available, otherwise the return-path; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "recipients" is made equivalent to "to"; if "null" is specified alone it will remove this header.
<sender> A single email address to appear in the From: and Return-Path: headers and become the sender.
It can include constants "sender", "postmaster" and "unaltered"; "sender" is equivalent to "unaltered".
Default: "unaltered".
<message> A text message to insert into the body of the email.
Default: no message is inserted.
<inline>

One of the following items:

  • unaltered     The original message is the new message, for forwarding/aliasing
  • heads          The headers of the original message are appended to the message
  • body           The body of the original is appended to the new message
  • all             ;   Both headers and body are appended
  • none            Neither body nor headers are appended
Default: "body".
<attachment>

One of the following items:

  • heads      The headers of the original are attached as text
  • body       The body of the original is attached as text
  • all           Both headers and body are attached as a single text file
  • none       Nothing is attached
  • message  The original message is attached as type message/rfc822, this means that it can, in many cases, be opened, resent, fw'd, replied to etc by email client software.
Default: "none".
<passThrough> true or false, if true the original message continues in the mailet processor after this mailet is finished. False causes the original to be stopped.
Default: false.
<fakeDomainCheck> true or false, if true will check if the sender domain is valid.
Default: true.
<attachError> true or false, if true any error message available to the mailet is appended to the message body (except in the case of inline == unaltered).
Default: false.
<replyTo> A single email address to appear in the Reply-To: header.
It can include constants "sender", "postmaster" "null" and "unaltered"; if "null" is specified it will remove this header.
Default: "unaltered".
<reversePath> A single email address to appear in the Return-Path: header.
It can include constants "sender", "postmaster" and "null"; if "null" is specified then it will set it to <>, meaning "null return path".
Notice: the "unaltered" value is not allowed.
Default: the value of the <sender> parameter, if set, otherwise remains unaltered.
<subject> An optional string to use as the subject.
Default: keep the original message subject.
<prefix> An optional subject prefix prepended to the original message subject, or to a new subject specified with the <subject> parameter.
For example: [Undeliverable mail].
Default: "".
<isReply> true or false, if true the IN_REPLY_TO header will be set to the id of the current message.
Default: false.
<debug> true or false. If this is true it tells the mailet to write some debugging information to the mailet log.
Default: false.
<static> true or false. If this is true it tells the mailet that it can reuse all the initial parameters (to, from, etc) without re-calculating their values. This will boost performance where a redirect task doesn't contain any dynamic values. If this is false, it tells the mailet to recalculate the values for each e-mail processed.
Default: false.

Example:


 <mailet match="RecipientIs=test@localhost" class="Redirect">
   <recipients>x@localhost, y@localhost, z@localhost</recipients>
   <to>list@localhost</to>
   <sender>owner@localhost</sender>
   <message>sent on from James</message>
   <inline>unaltered</inline>
   <passThrough>FALSE</passThrough>
   <replyTo>postmaster</replyTo>
   <prefix xml:space="preserve">[test mailing] </prefix>
   <!-- note the xml:space="preserve" to preserve whitespace -->
   <static>TRUE</static>
</mailet>

and:


 <mailet match="All" class="Redirect">
   <recipients>x@localhost</recipients>
   <sender>postmaster</sender>
   <message xml:space="preserve">Message marked as spam:</message>
   <inline>heads</inline>
   <attachment>message</attachment>
   <passThrough>FALSE</passThrough>
   <attachError>TRUE</attachError>
   <replyTo>postmaster</replyTo>
   <prefix>[spam notification]</prefix>
   <static>TRUE</static>
 </mailet>

replyto can be used instead of replyTo; such name is kept for backward compatibility.

RedirectNotify

Abstract mailet providing configurable redirection services.
This mailet can be subclassed to make authoring redirection mailets simple.
By extending it and overriding one or more of these methods new behaviour can be quickly created without the author having to address any other issue than the relevant one:

  • attachError() , should error messages be appended to the message
  • getAttachmentType(), what should be attached to the message
  • getInLineType(), what should be included in the message
  • getMessage(), The text of the message itself
  • getRecipients(), the recipients the mail is sent to
  • getReplyTo(), where replies to this message will be sent
  • getReversePath(), what to set the reverse-path to
  • getSender(), who the mail is from
  • getSubject(), a string to replace the message subject
  • getSubjectPrefix(), a prefix to be added to the message subject, possibly already replaced by a new subject
  • getTo(), a list of people to whom the mail is *apparently* sent
  • isReply(), should this mailet set the IN_REPLY_TO header to the id of the current message
  • getPassThrough(), should this mailet allow the original message to continue processing or GHOST it.
  • getFakeDomainCheck(), should this mailet check if the sender domain address is valid.
  • isStatic(), should this mailet run the get methods for every mail, or just once.

For each of the methods above (generically called "getX()" methods in this class and its subclasses), there is an associated "getX(Mail)" method and most times a "setX(Mail, Tx, Mail)" method.
The roles are the following:

  • a "getX()" method returns the correspondent "X" value that can be evaluated "statically" once at init time and then stored in a variable and made available for later use by a "getX(Mail)" method;
  • a "getX(Mail)" method is the one called to return the correspondent "X" value that can be evaluated "dynamically", tipically based on the currently serviced mail; the default behaviour is to return the value of getX();
  • a "setX(Mail, Tx, Mail)" method is called to change the correspondent "X" value of the redirected Mail object, using the value returned by "gexX(Mail)"; if such value is null, it does nothing.

Here follows the typical pattern of those methods:


   ...
   Tx x;
   ...
   protected boolean getX(Mail originalMail) throws MessagingException {
       boolean x = (isStatic()) ? this.x : getX();
       ...
       return x;
   }
   ...
   public void init() throws MessagingException {
       ...
       isStatic = (getInitParameter("static") == null) ? false : new Boolean(getInitParameter("static")).booleanValue();
       if(isStatic()) {
           ...
           X  = getX();
           ...
       }
   ...
   public void service(Mail originalMail) throws MessagingException {
   ...
   setX(newMail, getX(originalMail), originalMail);
   ...
   }
   ...

The isStatic variable and method is used to allow for the situations (deprecated since version 2.2, but possibly used by previoulsy written extensions to {@link Redirect}) in which the getX() methods are non static: in this case {@link #isStatic()} must return false.
Finally, a "getX()" method may return a "special address" (see {@link SpecialAddress}), that later will be resolved ("late bound") by a "getX(Mail)" or "setX(Mail, Tx, Mail)": it is a dynamic value that does not require isStatic to be false.

Supports by default the passThrough init parameter (false if missing). Subclasses can override this behaviour overriding {@link #getPassThrough()}.

RemoteDelivery

The RemoteDelivery mailet delivers messages to a remote SMTP server able to deliver or forward messages to their final destination.

The remote SMTP server through which each mail is delivered is resolved using MX lookup for each message destination unless the <gateway/> parameter is set. The <gateway/> parameter enables the definition of one or more gateway servers through which all messages are sent.

If an attempt to deliver a message fails, a redelivery attempt is scheduled according to the scheme defined by the <delayTime/> parameter, retrying up to the limit defined by the <maxRetries/> parameter. When the retry limit is exceeded, delivery failure is processed according to the setting of the <bounceProcessor/> parameter.

These are the parameters that control the operation of the RemoteDelivery mailet:

  • deliveryThreads (required) - an Integer for the number of threads this mailet will use to deliver mail.
  • outgoing (required) - a String containing the name of the queue that will hold messages being processed by this mailet.
  • bind (optional) - a String describing the local IP address to which the mailet should be bound while delivering emails. This tag is useful for multihomed machines. Default is to bind to the default local address of the machine.
    Note: The same IP address must be used for all of those RemoteDelivery instances where you explicitly supply a bind address.
  • delayTime (optional> a String containing a comma separated list of patterns defining the number of and delays between delivery attempts. The pattern is [attempts\*]delay [unit] where:
    • attempts (optional) - an Integer for the number of delivery attempts. Default is 1.
    • delay (required) - a Long for the delay between attempts.
    • unit (optional) - a String with the value of one of 'msec', 'sec', 'minute', 'hour', or 'day'. Default is msec.
    Default is one attempt after 6 hours, which if explicitly declared would be written as <delayTime>1 * 6 hour</delayTime>
  • maxRetries (optional) an Integer for the number of times an attempt is made to deliver a particular mail. Default is the greater of five and the sum of the attempts for each <delayTime/> specified.
  • maxDnsProblemRetries (optional) - an Integer for the number of times to retry if DNS problems for a domain occur. Default is 0.
  • timeout (optional) - an Integer for the Socket I/O timeout in milliseconds. Default is 180000
  • connectionTimeout (optional) - an Integer for the Socket connection timeout in milliseconds. Default is 60000
  • bounceProcessor (optional) - a String containing the name of the mailet processor to pass messages that cannot be delivered to for DSN bounce processing. Default is to send a traditional message containing the bounce details.
  • startTLS (optional) - a Boolean (true/false) indicating whether the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. Default is false.
  • sslEnable (optional) - a Boolean (true/false) indicating whether to use SSL to connect and use the SSL port unless explicitly overridden. Default is false.
  • gateway (optional) - a String containing a comma separated list of patterns defining the gateway servers to be used to deliver mail regardless of the recipient address. If multiple gateway servers are defined, each will be tried in definition order until delivery is successful. If none are successful, the mail is bounced. The pattern is host[:port] where:
    • host (required) - the FQN of the gateway server.
    • port (optional) - the port of the gateway server. Default is the value defined in the <gatewayPort/> parameter if set, else the default port for the specified connection type.
    Default is to resolve the destination SMTP server for each mail using MX lookup.
  • gatewayPort (optional) - an Integer for the gateway port to be used for each defined gateway server for which a port is not explicitly defined in the <gateway/> parameter. Default is the default port for the specified connection type.
  • gatewayUsername (optional) - a String containing the user name to be used to authenticate the user using the AUTH command. Default is not to issue the AUTH command.
  • gatewayPassword (required if gatewayUsername) is set - a String representing the password to be used to authenticate the user using the AUTH command.
  • heloName (optional) - a String containing the name used in the SMTP HELO and EHLO commands. Default is the default domain, which is typically localhost.
  • mail.* (optional) - Any property beginning with mail. described in the Javadoc for package com.sun.mail.smtp can be set with a parameter of the corresponding name. For example the parameter <mail.smtp.ssl.enable>true</mail.smtp.ssl.enable> is equivalent to the Java code props.put("mail.smtp.ssl.enable", "true");. Properties set by this facility override settings made within the mailet code.
    Note: This facility should be used with extreme care by expert users with a thorough knowledge of the relevant RFCs and the ability to perform their own problem resolutions.
  • debug (optional) - a Boolean (true/false) indicating whether debugging is on. Default is false.

RemoveAllMailAttributes

Mailet Info: Remove All Mail Attributes Mailet

This mailet sets removes all attributes set on the Mail instance Sample configuration:


<mailet match="All" class="RemoveAllMailAttributes"/>

RemoveMailAttribute

Mailet Info: Remove Mail Attribute Mailet

This mailet sets attributes on the Mail. Sample configuration:


<mailet match="All" class="RemoveMailAttribute">
  <name>attribute_name1</name>
  <name>attribute_name2</name>
</mailet>

RemoveMimeHeader

Mailet Info: RemoveMimeHeader Mailet

Remove mime headers Sample configuration:


<mailet match="All" class="RemoveMimeHeader">
<name>header1</name>
<name>header2</name>
</mailet>

ReplaceContent

Mailet Info: ReplaceContent

Replace text contents

This mailet allow to specific regular expression to replace text in subject and content.

Each expression is defined as: /REGEX_PATTERN/SUBSTITUTION_PATTERN/FLAGS/

REGEX_PATTERN is a regex used for the match
SUBSTITUTION_PATTERN is a substitution pattern
FLAGS flags supported for the pattern:
i: case insensitive
m: multi line
x: extended (N/A)
r: repeat - keep matching until a substitution is possible

To identify subject and body pattern we use the tags <subjectPattern> and <bodyPattern>

Rules can be specified in external files. Lines must be CRLF terminated and lines starting with # are considered commments. Tags used to include external files are <subjectPatternFile> and <bodyPatternFile> If file path starts with # then the file is loaded as a reasource.

Use of both files and direct patterns at the same time is allowed.

This mailet allow also to enforce the resulting charset for messages processed, when a replacement has been done. To do that the tag <charset> must be specified.

NOTE: Regexp rules must be escaped by regexp excaping rules and applying this 2 additional rules:
- "/" char inside an expression must be prefixed with "\": e.g: "/\//-//" replaces "/" with "-"
- when the rules are specified using <subjectPattern> or <bodyPattern> and "/,/" has to be used in a pattern string it must be prefixed with a "\". E.g: "/\/\/,//" replaces "/" with "," (the rule would be "/\//,//" but the "/,/" must be escaped.

Resend

A mailet providing configurable redirection services.

Can produce listserver, forward and notify behaviour, with the original message intact, attached, appended or left out altogether. Can be used as a replacement to {@link Redirect}, having more consistent defaults, and new options available.
Use Resend if you need full control, Redirect if the more automatic behaviour of some parameters is appropriate.

This built in functionality is controlled by the configuration as laid out below. In the table please note that the parameters controlling message headers accept the "unaltered" value, whose meaning is to keep the associated header unchanged and, unless stated differently, corresponds to the assumed default if the parameter is missing.

The configuration parameters are:

<recipients> A comma delimited list of addresses for recipients of this message.
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "from" is made equivalent to "sender", and "to" is made equivalent to "recipients"; "null" is ignored. Default: "unaltered".
<to> A comma delimited list of addresses to appear in the To: header.
Such addresses can contain "full names", like Mr. John D. Smith <john.smith@xyz.com>.
The list can include constants "sender", "from", "replyTo", "postmaster", "reversePath", "recipients", "to", "null" and "unaltered"; "from" uses the From header if available, otherwise the Sender header if available, otherwise the return-path; "replyTo" uses the ReplyTo header if available, otherwise the From header if available, otherwise the Sender header if available, otherwise the return-path; "recipients" is made equivalent to "to"; if "null" is specified alone it will remove this header. Default: "unaltered".
<sender> A single email address to appear in the From: header and become the sender.
It can include constants "sender", "postmaster" and "unaltered"; "sender" is equivalent to "unaltered".
Default: "unaltered".
<message> A text message to insert into the body of the email.
Default: no message is inserted.
<inline>

One of the following items:

  • unaltered     The original message is the new message, for forwarding/aliasing
  • heads          The headers of the original message are appended to the message
  • body           The body of the original is appended to the new message
  • all             ;   Both headers and body are appended
  • none            Neither body nor headers are appended
Default: "unaltered".
<attachment>

One of the following items:

  • heads      The headers of the original are attached as text
  • body       The body of the original is attached as text
  • all           Both headers and body are attached as a single text file
  • none       Nothing is attached
  • message  The original message is attached as type message/rfc822, this means that it can, in many cases, be opened, resent, fw'd, replied to etc by email client software.
Default: "none".
<passThrough> true or false, if true the original message continues in the mailet processor after this mailet is finished. False causes the original to be stopped.
Default: false.
<fakeDomainCheck> true or false, if true will check if the sender domain is valid.
Default: true.
<attachError> true or false, if true any error message available to the mailet is appended to the message body (except in the case of inline == unaltered).
Default: false.
<replyTo> A single email address to appear in the Reply-To: header.
It can include constants "sender", "postmaster" "null" and "unaltered"; if "null" is specified it will remove this header.
Default: "unaltered".
<reversePath> A single email address to appear in the Return-Path: header.
It can include constants "sender", "postmaster" "null" and "unaltered"; if "null" is specified then it will set it to <>, meaning "null return path".
Default: "unaltered".
<subject> An optional string to use as the subject.
Default: keep the original message subject.
<prefix> An optional subject prefix prepended to the original message subject, or to a new subject specified with the <subject> parameter.
For example: [Undeliverable mail].
Default: "".
<isReply> true or false, if true the IN_REPLY_TO header will be set to the id of the current message.
Default: false.
<debug> true or false. If this is true it tells the mailet to write some debugging information to the mailet log.
Default: false.

Example:


 <mailet match="RecipientIs=test@localhost" class="Resend">
   <recipients>x@localhost, y@localhost, z@localhost</recipients>
   <to>list@localhost</to>
   <sender>owner@localhost</sender>
   <message>sent on from James</message>
   <inline>unaltered</inline>
   <passThrough>FALSE</passThrough>
   <replyTo>postmaster</replyTo>
   <prefix xml:space="preserve">[test mailing] </prefix>
   <!-- note the xml:space="preserve" to preserve whitespace -->
   <static>TRUE</static>
</mailet>

and:


 <mailet match="All" class="Resend">
   <recipients>x@localhost</recipients>
   <sender>postmaster</sender>
   <message xml:space="preserve">Message marked as spam:</message>
   <inline>heads</inline>
   <attachment>message</attachment>
   <passThrough>FALSE</passThrough>
   <attachError>TRUE</attachError>
   <replyTo>postmaster</replyTo>
   <prefix>[spam notification]</prefix>
 </mailet>

The following example forwards the message without any modification, based on the defaults:


 <mailet match="All" class="Resend"/;>

replyto can be used instead of replyTo; such name is kept for backward compatibility.

WARNING: as the message (or a copy of it) is reinjected in the spool without any modification, the preceding example is very likely to cause a "configuration loop" in your system, unless some other mailet has previously modified something (a header for instance) that could force the resent message follow a different path so that it does not return here unchanged.

SMIMECheckSignature

Verifies the s/mime signature of a message. The s/mime signing ensure that the private key owner is the real sender of the message. To be checked by this mailet the s/mime signature must contain the actual signature, the signer's certificate and optionally a set of certificate that can be used to create a chain of trust that starts from the signer's certificate and leads to a known trusted certificate.

This check is composed by two steps: firstly it's ensured that the signature is valid, then it's checked if a chain of trust starting from the signer certificate and that leads to a trusted certificate can be created. The first check verifies that the the message has not been modified after the signature was put and that the signer's certificate was valid at the time of the signing. The latter should ensure that the signer is who he declare to be.

The results of the checks perfomed by this mailet are wrote as a mail attribute which default name is org.apache.james.SMIMECheckSignature (it can be changed using the mailet parameter mailAttribute). After the check this attribute will contain a list of SMIMESignerInfo object, one for each message's signer. These objects contain the signer's certificate and the trust path.

Optionally, specifying the parameter strip, the signature of the message can be stripped after the check. The message will become a standard message without an attached s/mime signature.

The configuration parameter of this mailet are summerized below. The firsts defines the location, the format and the password of the keystore containing the certificates that are considered trusted. Note: only the trusted certificate entries are read, the key ones are not.

  • keyStoreType (default: jks): Certificate store format . "jks" is the standard java certificate store format, but pkcs12 is also quite common and compatible with standard email clients like Outlook Express and Thunderbird.
  • keyStoreFileName (default: JAVA_HOME/jre/lib/security/cacert): Certificate store path.
  • keyStorePassword (default: ""): Certificate store password.
Other parameters configure the behavior of the mailet:
  • strip (default: false): Defines if the s/mime signature of the message have to be stripped after the check or not. Possible values are true and false.
  • mailAttribute (default: org.apache.james.SMIMECheckSignature): specifies in which attribute the check results will be written.
  • onlyTrusted (default: true): Usually a message signature to be considered by this mailet as authentic must be valid and trusted. Setting this mailet parameter to "false" the last condition is relaxed and also "untrusted" signature are considered will be considered as authentic.

SMIMEDecrypt

This mailet decrypts a s/mime encrypted message. It takes as input an encrypted message and it tries to dechiper it using the key specified in its configuration. If the decryption is successful the mail will be changed and it will contain the decrypted message. The mail attribute org.apache.james.SMIMEDecrypt will contain the public certificate of the key used in the process. The configuration parameters of this mailet are summarized below. The firsts define the keystore where the key that will be used to decrypt messages is saved.

  • keyStoreType (default: system dependent): defines the type of the store. Usually jks, pkcs12 or pkcs7
  • keyStoreFileName (mandatory): private key store path.
  • keyStorePassword (default: ""): private key store password
The other parameters define which private key have to be used. (if the store contains more than one key).
  • keyAlias: private key alias.
  • keyPass: private key password

SMIMESign

Mailet Info: SMIME Signature Mailet

Puts a server-side SMIME signature on a message. It is a concrete subclass of {@link Sign}, with very few modifications to it, to specialize for SMIME.

Handles the following init parameters (will comment only the differences from {@link AbstractSign}):

  • <debug>.
  • <keyStoreFileName>.
  • <keyStorePassword>.
  • <keyAlias>.
  • <keyAliasPassword>.
  • <keyStoreType>.
  • <postmasterSigns>. The default is true.
  • <rebuildFrom>. The default is true.
  • <signerName>.
  • <explanationText>. There is a default explanation string template in English, displaying also all the headers of the original message (see {@link #getExplanationText}).

SPF (Experimental)

Check the ip, sender, helo against SPF. Add the following attributes to the mail object:


 org.apache.james.transport.mailets.spf.explanation
 org.apache.james.transport.mailets.spf.result

Sample configuration:
<mailet match="All" class="SPF">
  <addHeader>true</addHeader>
  <debug>false</debug>
</mailet>

SerialiseToHTTP (Experimental)

Mailet Info: HTTP POST serialised message

Serialise the email and pass it to an HTTP call Sample configuration: URL url where serialised message will be posted ParameterKey An arbitrary parameter be added to the post ParameterValue A value for the arbitrary parameter MessageKeyName Field name for the serialised message passThrough true or false

ServerTime (Experimental)

Mailet Info: ServerTime Mailet

Returns the current time for the mail server. Sample configuration:


<mailet match="RecipientIs=time@cadenza.lokitech.com" class="ServerTime">
</mailet>

SetMailAttribute

Mailet Info: Set Mail Attribute Mailet

This mailet sets attributes on the Mail.

Sample configuration:


<mailet match="All" class="SetMailAttribute">
  <name1>value1</name1>
  <name2>value2</name2>
</mailet>

SetMimeHeader

Mailet Info: SetMimeHeader Mailet

Adds a specified header and value to the message.

Sample configuration:


<mailet match="All" class="AddHeader">
  <name>X-MailetHeader</name>
  <value>TheHeaderValue</value>
</mailet>

Sieve

Execute Sieve scripts for incoming emails, and set the result of the execution as attributes of the mail

Sign

Mailet Info: Signature Mailet

Puts a server-side signature on a message. It is a concrete subclass of {@link AbstractSign}, with very few modifications to it.

A text file with an explanation text is attached to the original message, and the resulting message with all its attachments is signed. The resulting appearence of the message is almost unchanged: only an extra attachment and the signature are added.

The kind of signuture depends on the value of the <keyHolderClass> init parameter.

Handles the following init parameters (will comment only the differences from {@link AbstractSign}):

  • <keyHolderClass>: Sets the class of the KeyHolder object that will handle the cryptography functions, for example org.apache.james.security.SMIMEKeyHolder for SMIME.
  • <debug>.
  • <keyStoreFileName>.
  • <keyStorePassword>.
  • <keyAlias>.
  • <keyAliasPassword>.
  • <keyStoreType>.
  • <postmasterSigns>. The default is true.
  • <rebuildFrom>. The default is true.
  • <signerName>.
  • <explanationText>. There is a default explanation string template in English, displaying also all the headers of the original message (see {@link #getExplanationText}).

SpamAssassin (Experimental)

Mailet Info: Checks message against SpamAssassin

Sends the message through daemonized SpamAssassin (spamd), visit spamassassin.apache.org/ for info on configuration. The header X-Spam-Status is added to every message, this contains the score and the threshold score for spam (usually 5.0). If the message exceeds the threshold, the header X-Spam-Flag will be added with the value of YES. The default host for spamd is localhost and the default port is 783.


 org.apache.james.spamassassin.status - Holds the status
 org.apache.james.spamassassin.flag   - Holds the flag

Sample Configuration:
<mailet notmatch="SenderHostIsLocal" class="SpamAssassin">
<spamdHost>localhost</spamdHost>
<spamdPort>783</spamdPort>

StripAttachment

Mailet Info: StripAttachment

Remove attachments from a Message. Supports simple removal, storing to file, or storing to mail attributes.

Configuration:

  <mailet match="All" class="StripAttachment" >
    <pattern >.*\.xls </pattern>  <!-- The regular expression that must be matched -- >
    <!-- notpattern >.*\.xls </notpattern-->  <!-- The regular expression that must be matched -- >
    <mimeType>text/calendar</mimeType>  <!-- The matching mimeType -- >
    <directory >c:\temp\james_attach </directory>   <!-- The directory to save to -- >
    <remove >all </remove>   <!-- either "no", "matched", "all" -- >
    <!-- attribute>my.attribute.name</attribute -->
  </mailet >
  
  At least one of pattern, notpattern and mimeType is required.

TerminatingMailet

Mailet which protect us to not fall into an endless loop caused by an configuration error

ToProcessor

Mailet Info: ToProcessor Mailet

This mailet redirects the mail to the named processor

Sample configuration:


<mailet match="All" class="ToProcessor">
  <processor>spam</processor>
  <notice>Notice attached to the message (optional)</notice>
</mailet>

ToRecipientFolder

Receives a Mail from the Queue and takes care to deliver the message to a defined folder of the recipient(s). You have to define the folder name of the recipient(s). The flag 'consume' will tell is the mail will be further processed by the upcoming processor mailets, or not.

<mailet match="RecipientIsLocal" class="ToRecipientFolder">
   <folder> Junk </folder>
   <consume> false </consume>
</mailet>

ToRepository

Mailet Info: ToRepository Mailet

Stores incoming Mail in the specified Repository.
If the "passThrough" in conf is true the mail will be returned untouched in the pipe and may be processed by additional mailets. If false will be destroyed.

ToSenderFolder (Experimental)

Receives a Mail from the Queue and takes care to deliver the message to a defined folder of the sender. You have to define the folder name of the sender. The flag 'consume' will tell is the mail will be further processed by the upcoming processor mailets, or not.

<mailet match="RecipientIsLocal" class="ToSenderFolder">
   <folder> Sent Items </folder>
   <consume> false </consume>
</mailet>

UnwrapText (Experimental)

Mailet Info: UnwrapText

Remove (best effort to) the hardcoded wrapping from a message.
If the text is "format=flowed" then deflows the text. Otherwise it forces a dewrap of the text.

Parameters:
quotewidth - when we try to dewrap e quoted text it helps knowing the original with, so we can reconstruct "wrapped wraps" created by multiple wrappings by clients with different original width or simply to the add of the heading ">" that increase the line length.
The value should be "WIDTH+X" if the original length is known, "-X" otherwise. In the latter case the length of the longer line will be used. X is the tollerance needed for the quoting chars: if the original width is known the suggested value for X is 2 (because of "> " prefix), otherwise it is suggested to increase it to a value like 10 (-10)

In summary, if the original wrap is known (for example 76, for flowed messages)
quotewidth = 78
Otherwise
quotewidth = -10

UseHeaderRecipients (Experimental)

Mailet Info: UseHeaderRecipients Mailet

Mailet designed to process the recipients from the mail headers rather than the recipients specified in the SMTP message header. This can be useful if your mail is redirected on-route by a mail server that substitutes a fixed recipient address for the original.

To use this, match against the redirection address using the RecipientIs matcher and set the mailet 'class' to UseHeaderRecipients. This will cause the email to be re-injected into the root process with the recipient substituted by all the recipients in the Mail-For, To and Cc headers of the message.

e.g.


   <mailet match="RecipientIs=forwarded@myhost"
           class="UseHeaderRecipients">
   </mailet>

UsersRepositoryAliasingForwarding (Experimental)

Receives a Mail from JamesSpoolManager and takes care of delivery of the message to local inboxes. Available configurations are: <enableAliases>true</enableAliases>: specify wether the user aliases should be looked up or not. Default is false. <enableForwarding>true</enableForwarding>: enable the forwarding. Default to false.

WhiteListManager (Experimental)

Mailet Info: White List Manager mailet

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>

WrapText (Experimental)

Mailet Info: WrapText

Convert a message to format=flowed

XMLRecipientRewriteTable (Experimental)

Mailet Info: XML Virtual User Table mailet

Implements a Virtual User Table to translate virtual users to real users. This implementation has the same functionality as JDBCRecipientRewriteTable, but is configured in the JAMES configuration and is thus probably most suitable for smaller and less dynamic mapping requirements.

The configuration is specified in the form:

<mailet match="All" class="XMLRecipientRewriteTable">
  <mapping>virtualuser@xxx=realuser[@yyy][;anotherrealuser[@zzz]]</mapping>
  <mapping>virtualuser2@*=realuser2[@yyy][;anotherrealuser2[@zzz]]</mapping>
  ...
</mailet>

As many <mapping> elements can be added as necessary. As indicated, wildcards are supported, and multiple recipients can be specified with a semicolon-separated list. The target domain does not need to be specified if the real user is local to the server.

Matching is done in the following order:

  1. user@domain - explicit mapping for user@domain
  2. user@* - catchall mapping for user anywhere
  3. *@domain - catchall mapping for anyone at domain
  4. null - no valid mapping