Postfix: log message from, to and subject
Published: 28-03-2009 | Author: Remy van Elst | Text only version of this article
❗ This post is over thirteen years old. It may no longer be up to date. Opinions may have changed.
This is a little trick for Postfix, it lets you log the
to of all the emails postfix sends (or which pass through it if you run it as
a relay). It comes in handy when you need to debug an email issue and need to
confirm your mailserver has sent the message.
I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!
Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.
You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.
First create the file
/etc/postfix/header_checks and insert this into it:
/^subject:/ WARN /^to:/ WARN /^from:/ WARN /^Subject:/ WARN /^To:/ WARN /^From:/ WARN
Now, in your postfix
/etc/postfix/main.cf add the following to the end of the
header_checks = regexp:/etc/postfix/header_checks
And restart postfix:
service postfix restart
You will hopefully now get log items like below, and if not you have a problem with your mailserver:
Tags: logging , mail , mta , postfix , tutorials
Dec 4 08:23:05 localhost postfix/cleanup: 90CA714: warning: header Subject: This is a testmail which gets logged from localhost[127.0.0.1]; from=<root@localhost> to=<root@localhost> proto=ESMTP helo=<localhost>