11

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?

  • 1
    Surely this must be a useless use of cat? At the very least you can do grep "smtp.*to=.*" /var/log/syslog | grep -v 250 – a CVn Jan 21 '14 at 13:36
  • Personally I find that crusade a bit pedantic in most contexts and prefer the OP's more readable, modular format – jchook Nov 2 '19 at 20:18
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.

| improve this answer | |
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.

| improve this answer | |
1

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/

| improve this answer | |
  • Why are you using smart quotes? They won't work. – DavidPostill Oct 19 '16 at 16:53
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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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