Reaching out to others! Free & Open Source Software, Kannada, L10n, L18n Data Science, Cloud Computing & more…

Log Subject line in Sendmail maillog

Gnu/Linux, linux, QuickFix, Technical | 0 comments

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)

LOCAL_CONFIG
Klog syslog
LOCAL_RULESETS
HSubject: $>+CheckSubject
SCheckSubject
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

Enjoy!

Tags: , , , ,

Related Articles

Related