Why add subject to postfix logging
If you are running your own email server, you might have gotten a question if an email has been handled correctly. And since users mostly only remember the subject of the message, it is useful to have that in the logging of postfix, so you can search for that.
By default postfix does not log the subject for security reasons, but if you are running a personal email server, it can help in debugging.
This does not block or change the emails in any way, it just adds a log line with the queue id and subject.
How to configure
To get the subject (or any header) in the log file, you have to create a
file which searches the message
headers for a line.
So create a file named /etc/postfix/header_checks with the following
content:
/^subject:/ INFOAnd to use this file, add the following to /etc/postfix/main.cf:
header_checks = regexp:/etc/postfix/header_checksWhen that is done, you can reload or restart postfix to activate the changes and after sending a message to that email server, you should see something like the following in the log:
Reload/restart Postfix and send a test message. You’ll see something like the following in your logs (on 1 line):
2025-04-06T21:21:40.033969+02:00 localhost postfix/cleanup[1228008]:
0581213A0381: info: header Subject: test Sun, 06 Apr 2025 21:21:38 +0200
from localhost[::1]; from=<user@localhost> to=<user@localhost>
proto=ESMTP helo=<localhost>Note that older versions of Postfix only support ‘WARN’ instead of ‘INFO’, so you may need to use that instead.
This post was based on the information on http://chillidoor.com/blog/log-subject-lines-in-postfix/.