How to Log Subject fields into /var/log/maillog file

You want to log email Subject field into /var/log/maillog?

By default the email subject field is not logged to the maillog file. To log it, here is the trick.

Edit /etc/postfix/main.cf and uncomment  the option below:

header_checks = regexp:/etc/postfix/header_checks

In the ‘/etc/postfix/header_checks’ file, write the line below in one line:

/^Subject:/ WARN

Then reload the postfix service using “postfix reload”

Tail the maillog file, you should see some logs similar like below:

Oct 26 18:32:28 mx-1 postfix/smtpd[7532]: 8C7255798B: client=unknown[xxx.xx.31.166], sasl_method=LOGIN, sasl_username=user@mydomain.com
Oct 26 18:32:28 mx-1 postfix/cleanup[6701]: 8C7255798B: warning: header Subject: Room Rate - Weatherford Company from unknown[xxx.xx.31.166]; from= to= proto=ESMTP helo=
Oct 26 18:32:28 mx-1 postfix/cleanup[6701]: 8C7255798B: message-id=<0CFA5E16DE5D67499273CF31D3949F7201B5FA0C@MEEXCH01.wft.root.loc>
Oct 26 18:32:28 mx-1 postfix/qmgr[19610]: 8C7255798B: from=, size=70837, nrcpt=1 (queue active)

Ref: http://www.irbs.net/internet/postfix/0410/2142.html