Postfix (Email) - Viewing email headers (TO FROM SUBJECT)

by
Jeremy Canfield |
Updated: February 21 2023
| Postfix (Email) articles
To view email header, such as TO and FROM and SUBJECT, add the following to /etc/postfix/main.cf.
header_checks = regexp:/etc/postfix/header_checks
Add the following to /etc/postfix/header_checks.
/To:.*/ INFO
/To:.*/ INFO
/From:.*/ INFO
/Subject:.*/ INFO
/Date:.*/ INFO
Use the postmap command to create or update the /etc/postfix/header_checks.db file.
postmap /etc/postfix/header_checks
The strings command can be used to verify that the /etc/postfix/header_checks.db file was created/updated.
~]$ strings /etc/postfix/header_checks.db
INFO
/to:.*/
INFO
/subject:.*/
INFO
/from:.*/
INFO
/date:.*/
INFO
/to:.*/
Restart Postfix.
systemctl restart postfix
Send a simple test email to yourself.
echo test | mail -s "my subject" john.doe@example.com
And now /var/log/maillog should have events like this.
Feb 21 09:06:00 smtp postfix/cleanup[18750]: EE4768B75DD: info: header Date: Tue, 21 Feb 2023 09:05:29 +0000 from unknown[10.22.5.104]; from=<john.doe@example.com> to=<john.doe@example.com> proto=ESMTP helo=<stmp.example.com>
Feb 21 09:06:00 smtp postfix/cleanup[18750]: EE4768B75DD: info: header From: jeremy.canfield@freekb.net from unknown[10.22.5.104]; from=<john.doe@example.com> to=<john.doe@example.com> proto=ESMTP helo=<stmp.example.com>
Feb 21 09:06:00 smtp postfix/cleanup[18750]: EE4768B75DD: info: header To: jeremy.canfield@freekb.net from unknown[10.22.5.104]; from=<john.doe@example.com> to=<john.doe@example.com> proto=ESMTP helo=<stmp.example.com>
Feb 21 09:06:00 smtp postfix/cleanup[18750]: EE4768B75DD: info: header Subject: my subject from unknown[10.22.5.104]; from=<john.doe@example.com> to=<john.doe@example.com> proto=ESMTP helo=<stmp.example.com>
Did you find this article helpful?
If so, consider buying me a coffee over at