I'm trying to set up a relay server using Postfix as MTA, and I need to log the server's mail usage (either to file or SQL). The idea is to monitor the amount of mails sent by host, and their size.
I've looked at several possibilities for this kind of traffic accounting in Postfix. They can be summed up as:
- A daemon running to intercept port 25 traffic, log it, then send the request to Postfix
- Log file analyzers that determine # mails sent & mail size via the /var/log/maillog (written in python, C-code, ...)
Analyzing log files will cause bounced mails being resent to count as doubles, while the daemon that's intercepting incoming port 25 won't notice Postfix re-running it's onhold-queue. So there's bound to be differences in both way of 'traffic accounting'.
Some examples include:
- MySQMail-Postfix-Logger: http://freshmeat.net/projects/mysqmail-postfix-logger
- pflogsumm (by Postfix)
But none seem to be able to give very detailed information. I prefer to log as much as possible (requesting IP, mailsize, from, to, mail-id, receiving mta, ...).
Do you have any experience with it? Are there recommendations, or things to look out for?
Use a policy daemon http://www.postfix.org/SMTPD_POLICY_README.html a good one that does accounting is policyd http://www.policyd.org/
It will log all the information you require to a database.