Rule based archival for netqmail


EQ Forum Admin
Staff member
I figured this was worth pointing out since some states and companies have this feature as an email requirement.



Recently someone asked me to develop an archival scheme for IndiMail at

as part of implementing compliance to standards like SOX, etc. This
scheme allows
unique archival destination email address for each recipient or
sender. You can also
use another domain for the archival and hence have the archival emails going to
a totally different server. It was easy for me to change the code for
netqmail and make
it available at

Browse IndiMail Files on

The patch modifies qmail-queue and the man page for qmail-queue


if the control file mailarchive exists, its content can be used for rule based


where type is F or T. If type is F, rule is appled on the sender. If type is
T, the rule is applied on the recipient. type can be omitted to match all
recipients. regexp is an expression to match the address (sender or recipient
as specfied by type) and dest_mailbox is a valid email address. regexp can be
omitted to match any address. A % in dest_mailbox followed by u, d or e gets
replaced as below

%u - user component in address without the ’@’ sign
%d - domain component in address
%e - email address


will add to qmail-queue's recipient list when a mail is
addressed to

As stated above, the address used for matching regexp is the sender in case
type is F. For bounces, you can use <> to match a null sender. e.g.


When a rule matches a sender or any one of the recipients, the dest_mailbox
address after expansion will be added to the existing recipient list. When a
rule matches multiple recipients, only one email address will be added to
recipient list to avoid duplicates.

The below will make a copy all mails for domain yourdomain to archyourdomain

I offer no warranty for the code. If you find bugs, report it to me
and I shall be happy
to fix it.

Note: The code is also part of a gigantic patch to qmail
(which is essentially the MTA component of IndiMail platform)