Postfix – Enable logging of email’s subject in maillog

By default postfix only capture ‘From’ and ‘To’ details in the log file (/var/log/maillog). There are some scenarios where we want that email’s subject should be capture in the maillog. In this article we will discuss how to achieve this :

We are assusming that postfix is already up and running and will make below changes.

Step:1 Edit ‘/etc/postfix/’ file & uncomment below line:

#header_checks = regexp:/etc/postfix/header_checks

Step:2 Append the below line in ‘/etc/postfix/header_checks’

/^Subject:/     WARN

Step:3 Restart the postfix server

#service postfix restart
#postmap /etc/postfix/header_checks

Step:4 Now do testing and send a test mail & see the logs


As we can see above , that info user has send email to gmail id with the subject “Linux Interview Call Details” .

Now see the maillogs using the command ‘tailf /var/log/maillog


Share on:

I am a Cloud Consultant with over 15 years of experience in Linux, Kubernetes, cloud technologies (AWS, Azure, OpenStack), automation (Ansible, Terraform), and DevOps. I hold certifications like RHCA, CKA, CKAD, CKS, AWS, and Azure.

3 thoughts on “Postfix – Enable logging of email’s subject in maillog”

  1. Thanks, very useful. Sorry for my silly question, but what if I wanted to use pcre instead regexp in my header_checks? What is the difference between those two?


Leave a Comment