Log Subject line in Sendmail maillog

Fighting spam is always a tough job. Why not log some specific headers to to make sysadmin’s job easier.

On servers it would be nice to see Subject line appearing in maillog. To get hold of the domain / user sending out emails with some specific subject line. By default you won’t see it happening. Here is how you can do it:

In /etc/mail folder open sendmail.mc in your favorite editor and add the following lines at the bottom (just to ensure that you can differentiate them easily)

Klog syslog
HSubject: $>+CheckSubject
R$*< Give a TAB HERE >$: $(log Subject: $1 $) $1

Ensure that you remove < Give a TAB HERE > from the last line and press TAB key before saving the file.

Once this is done, generate sendmail.cf as follows:

m4 sendmail.mc > sendmail.cf

Restart sendmail and that’s it. You will now be able to see Subject line appearing in /var/log/maillog


Tags: , , , ,

Published by


Gnu/Linux Enthusiast, Kannadiga, Wikipedian, Amateur photographer, trekker and more

Leave a Reply

Your email address will not be published. Required fields are marked *