14

I'm using GNU Mailman with Postfix to run a mailing list, and would like to monitor the delivery of outgoing mail, that is: for each mail sent from the list, check whether a 250 (OK) message was answered, and if not, report back to me.

For now, I'm doing a quick-and-dirty:

# cat /var/log/syslog | grep "smtp.*to=.*" | grep -v 250

Is there a clean way to monitor smtpd's output?

Tastalian
  • 243

6 Answers6

8

There is no way to monitor the sent mails in a clean way. You can only grep the details from the maillog of postfix.

Here is an example:

log='logfile of postfix'
grep "status=sent" $log | \
egrep -ve 'postfix/(cleanup|pickup|master|qmgr|smtpd|local|pipe)'

And also avoid the logs for dkim etc. If you need the count of mails then pipe on wc -l at the end.

rm-vanda
  • 240
mailer
  • 216
3

How about:

multitail -eX "smtp.*to=<(.*)>.*sent.*250" './bin/received' -f /var/log/maillog

./bin/received is a shell script that gets the destination email address as a parameter and does something with it.

2

try this

cat /var/log/maillog |grep -v "relay=local" |grep "relay=" |grep "status=sent"

you will find very helpful info here http://en.redinskala.com/postfix-maillog-interpretation/

2

You can use pflogsumm to get an overview of entries in the logs:

cat /var/log/mail.log | pflogsumm

Grand Totals

messages

 26   received
 25   delivered
  0   forwarded
  0   deferred
  2   bounced
  0   rejected (0%)
  0   reject warnings
  0   held
  0   discarded (0%)

752k  bytes received
751k  bytes delivered
 14   senders
  7   sending hosts/domains
  3   recipients
  3   recipient hosts/domains


Per-Day Traffic Summary

date          received  delivered   deferred    bounced     rejected
--------------------------------------------------------------------
May  7 2023         7          7 
May  8 2023        11         10          0          2 
May  9 2023         8          8 

Another option is Lightmeter which is able to notify you when something happens, although I cannot recommend it.

cweiske
  • 2,191
0

I am watching who sends email through my server with this:

tail -f /var/log/mail.log | grep 'sasl'

It shows who the authenticated user is who's sending.

0

Note that other information than the 250 can still be relevant to what constituted a successful delivery.

For example a successfully sent message that was marked as spam could have a message looking like this:

... status=sent (250 2.0.0 OK DMARC:Quarantine ...)
DZet
  • 113
  • 3