Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

CentOS 5.8

I'd like to be able to track an email based on Subject line. The default log of 9 in SendMail doesn't appear to include that information.

My questions are:

  • What is the minimum sendmail log level that includes this information?
  • Is there a way to add the subject-line to log events at the default log level?
share|improve this question

I found this on the net when looking up the same thing. I didnt come up with this, but it'll get your CentOS5 box logging subjects in /var/log/maillog.

I added this to the end of my

Klog syslog
HSubject: $>+CheckSubject

R$*     $: $(log Subject: $1 $) $1

*after R$* in the last line that MUST be a tab**

Run m4 and generate a new cf file and restart:

m4 > /etc/init.d/sendmail restart

My logs now show this:

Dec  5 19:09:42 site sendmail[23327]: qB609gWD023327: from=apache, size=1728, class=0, nrcpts=1, msgid=<>, relay=apache@localhost 
Dec  5 19:09:42 site sendmail[23328]: qB609gK9023328: Subject: Test1234  
Dec  5 19:09:42 site sendmail[23328]: qB609gK9023328: from=<>, size=1953, class=0, nrcpts=1, msgid=<>, proto=ESMTP, daemon=MTA, []

I wish it didnt log the subject on a seperate line, but it does allow you to track emails by subject.

share|improve this answer
Nice! Thanks for the post. – Mike B Dec 6 '12 at 23:18

You can do this by installing the MIMEDefang milter and then supplying your own version of filter_relay() which then can call md_syslog() and log whatever you want.

share|improve this answer

I'm afraid that you won't be able to do that with a stock version of sendmail. You may want to roll your own by compiling sendmail after applying a patch like this, which should solve your problem.

share|improve this answer

If you are open to changing your email software, Exim allows you to add the Subject to the log. It can also be built to allow access to a database from the configuration file. This can be used to log whatever information you want. It is functionally equivalent to sendmail.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.