18.10 Logging All Mail

Some organizations need to log all email passing in or out of their system. An obscure feature called QUEUE_EXTRA makes this quite straightforward. Every time qmail-queue enqueues a message, it adds the string QUEUE_EXTRA to the recipient addresses. Normally that string is empty, but you can edit extra.h in the qmail source code to be whatever you want. The usual change (recommended in the qmail FAQ) is to make it add a recipient called log to each message. Change QUEUE_EXTRA to be the exact string to add to the recipient string including the leading T and trailing null, and set QUEUE_EXTRALEN to be the length of the string. Then rebuild and reinstall qmail. See Example 18-6.

Example 18-6. Code in extra.h to copy everything to log
#define QUEUE_EXTRA "Tlog\0" #define QUEUE_EXTRALEN 5

Now every message will be copied to the address log, so you can create ~alias/.qmail-log to save the mail:

./logmaildir/

The .qmail file must save the mail but cannot forward it. Why not? Because forwarding mail invokes qmail-queue again, which will redeliver the mail to log, creating a nasty mail loop.



qmail
qmail
ISBN: 1565926285
EAN: 2147483647
Year: 2006
Pages: 152

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net