Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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?

share|improve this question
up vote 1 down vote accepted

Use a policy daemon a good one that does accounting is policyd

It will log all the information you require to a database.

share|improve this answer
a policy daemon will not log correctly message sizes: > The "size" attribute value specifies the message size that the client specified in the MAIL FROM command (zero if none was specified). With Postfix 2.2 and later, it specifies the actual message size when the client sends the END-OF-DATA command. – idragosalex Mar 18 at 17:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.