2

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?

1 Answer 1

2

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.

1
  • 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. Mar 18, 2016 at 17:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .