Please select one of the following releases. We currently have a pre-compiled package for FreeBSD i386 which can be installed via the pkg_add command or a source distribution with autotools configure and build scripts, which should work on most systems. Please note that libmilter v1.0.0 is the minimum version required to build this project from sources (this version ships with sendmail 8.14.0 and later, though we recommend using 8.14.3 or newer). Installation instructions are provided below.

archivesmtp-1.2.tar.gz1.2Release Source

If your system already has libmilter and the required headers, installation from source should be simple as unpackaging the archive and issuing the following commands as root in the top level of the source directory:

make install

If the configure step reports problems you should check the config.log for details, though it is most likely due to your system not having libmilter installed (many linux distributions do not install it as part of their default configuration, even if you selected to install sendmail) or the library version is too old, you will need the library included in sendmail 8.14.0 or later (we recommend at least 8.14.3). To obtain a copy of libmilter you should visit and download a recent version of sendmail (Don't use sendmail? Don't worry, we are only installing the library, which even if you use a different MTA must be built from the sendmail sources). You should consult the sendmail documentation for specifics, however the basic procedure is to unpackage the sources, enter the 'libmilter' sub-directory and issue the command 'make install', after which ArchiveSMTP should build without error for you.

Once ArchiveSMTP has been installed you will need to configure your MTA to use it as a filter. This step will vary depending on which MTA you use, however you must first select a socket type and location for communications with your MTA. We recommend that you use a unix socket (local and inet are also supported) and place it in a path like /var/run/archivesmtp/mta.sock. The path for this socket should be owned by the user ArchiveSMTP will run as and only be writable by the owner (it is an error to have group or all with write access). To use this path you would invoke ArchiveSMTP with the -p flag set to "unix:/var/run/archivesmtp/mta.sock". Once you have selected where you want your socket, the MTA must be configured to use it. Please consult the documentation for your MTA regarding the use of milters for details. Under sendmail you would need to add the following to your file (after which you must process it into a .cf file and reload sendmail):

INPUT_MAIL_FILTER(`filter1', `S=unix:/var/run/archivesmtp/mta.sock')
define(`confINPUT_MAIL_FILTERS', `filter1')

Alternatively you could insert these lines directly into your file:

Xfilter1, S=unix:/var/run/archivesmtp/mta.sock
O InputMailFilters=filter1

You are now ready to go! You will want to create some rules first. The config file contains a list of rules, each rule has the following format:

Where TEST_LIST describes the tests a mail must pass and ACTION_LIST describes the actions taken should it pass. Actions that produce output are in mbox format. All tests may be negated using the exclamation mark syntax, including brackets (eg. !Sender, !(cond1 and cond2), etc).

A test follows the following format:


So for example, a test might be:

Sender starts "Fred"

Valid values for FIELD_TO_TEST are:
    Sender - The username of the sender from SMTP Auth (or null if not auth'd).
    From   - The "From:" address in the mail header.
    To     - All recipient addresses, including "To:", "Cc:" and "Bcc:".
Note: Sender is CASE sensitive; the others are not.

Valid values for LOCATION_IN_FIELD are:
    Starts   - Matches the start of the string.
    Ends     - Matches the end of the string.
    Contains - Matches any location in the string.
    Is       - Test and string must be exactly the same.

TEST_TEXT is a string. By default it is delineated by whitespace, but you can surround it with "double quotes" if you like and backslash "\" escapes are honoured.

There are also two special tests that require no location or test string:
    Not Matched - Will match if no previous rule has matched the mail.
    Match All   - Will match everything.

The ACTION_LIST is a list of comma "," separated actions to take should the rule match the input e-mail. The list is terminated by a semi-colon ";". Each rule MUST have at least one action.

An action has the following format:


For example:

Store In "/path/to/file"

Valid values for ACTION_TYPE are:
    Store In   - On match the e-mail should be stored in the file given in ARG.
               * ARGUMENT must be a valid path including the file name.
    Add Header - On match the header given in ARG will be added to the e-mail.
               * ARGUMENT must be in the format "field:value".
    Pipe       - On match the e-mail data will be piped to the program in ARG.
               * ARGUMENT must be an executable program with required flags.
    Halt       - On match no further rules will be tested.
               * Has no arguments.

The action ARGUMENTS are a single case sensitive string, you can enclose them in "double quotes" to include whitespace characters. Characters can also be escaped by with backslash "\". Token substitution is provided for in all action arguments, you may use as many tokens as you wish. Tokens must be in UPPERCASE between percent "%" characters.

Supported tokens are:
    %%       - A literal % is inserted.
    %SENDER% - Username of the sender is inserted if set, otherwise nothing.
    %FROM%   - The from address is inserted.
    %TO%     - The FIRST matched to address is inserted. *Note: This token will be EMPTY unless at least one To test matches something.
    %ALLTO%  - This is a special case token and will cause the rule action that uses this token to be run once for every to address that can be matched by the rule, substituting a different address each pass. *Note: This token will be EMPTY unless at least one To test matches something.

Note: All tokens also support .USER and .DOMAIN specifiers which will cause them to insert only the part before (user) or after (domain) the @ symbol (eg. if the to address is then %TO.DOMAIN% would insert '' while %TO.USER% would insert 'foo').

You can use multiple conditions to create more complex expressions using the Or and And keywords as well as bracket grouping. For example:

To starts "Fred" and From starts "Joe"

is valid. "and" and "or" both work. You can also use brackets:

{ Sender contains "Bloggs" and (To starts "Fred" or !From ends "Green") } store in /maillogs/%SENDER.USER%.mbox, pipe "procmail", halt;

is a valid rule. You can find some more examples in the sample configuration file included.