Entry
How do I log incoming and outgoing email?
Dec 22nd, 2003 19:01
Stephen Lombard,
It is possible to log all incoming and outgoing email from qmail into
one file to read with mutt or whatever flavour of mailreader suits you.
To do this, place a .qmail-log file in the alias directory (eg:
/var/qmail/alias) with the following entry:
./msg-log
This will write a file (msg-log) to /var/qmail/alias/msg-log. If you
wish for it to be written elsewhere, ensure that the correct write
permissions are set for qmail to write to that destination.
As a side note, you can also run scripts for incoming and outgoing
emails from the .qmail-log file:
|/usr/local/bin/msg-log/msg-log.pl
./msg-log
This will pass the email to our script and record it in the msg-log
file. This is useful to reformat headers, perform pre-processing or any
other tasks required for incoming and outgoing messages.
The msg-log file will no doubt become large so it is a good idea to
rotate the logs. I simply use a script called from cron.
logrotate:#!/bin/bash
cd /var/qmail/alias
tar -zcvf msg-`date +%Y-%m-%d`-log.tar.gz msg-log
rm msg-log
Good Luck! I hope this helps.