Skip to main content Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Postfix: log message from, to and subject

Published: 28-03-2009 | Author: Remy van Elst | Text only version of this article

Table of Contents

This is a little trick for Postfix, it lets you log the subject, from andto of all the emails postfix sends (or which pass through it if you run it asa relay). It comes in handy when you need to debug an email issue and need toconfirm your mailserver has sent the message.

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

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/ add the following to the end of thefile:

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 problemwith your mailserver:

Dec  4 08:23:05 localhost postfix/cleanup[2278]: 90CA714: warning: headerSubject: This is a testmail which gets logged from localhost[];from=<root@localhost> to=<root@localhost> proto=ESMTP helo=<localhost>
Tags: logging, mail, mta, postfix, tutorials