Here is a minor patch for Sendmail 8.13.8. The patch enables two additional features:

  • optional logging of message's Subject: headers
  • optional disabling of "null connection" alert logging for certain allowed hosts

    NOTE!! Using this patch on a public production mail server may violate users' privacy because Subject: header
    is certainly part of the message's PRIVATE CONTENT! It cannot be considered as metadata like, say,
    Received headers can!

    If you have GNU tools, the whole process (extract source, apply patch, compile) could go like this:

    linuxhost:/home/user/src$ tar zxf sendmail.8.13.8.tar.gz                     
    linuxhost:/home/user/src$ patch -p0 < sendmail.8.13.8-subject-logging-patch.diff 
    patching file sendmail-8.13.8/cf/m4/cfhead.m4
    patching file sendmail-8.13.8/cf/m4/proto.m4
    patching file sendmail-8.13.8/sendmail/conf.c
    patching file sendmail-8.13.8/sendmail/deliver.c
    patching file sendmail-8.13.8/sendmail/readcf.c
    patching file sendmail-8.13.8/sendmail/sendmail.h
    patching file sendmail-8.13.8/sendmail/srvrsmtp.c
    patching file sendmail-8.13.8/sendmail/version.c
    linuxhost:/home/user/src$ cd sendmail.8.13.8
    linuxhost:/home/user/src$ make
    

    [delightful messages about smoothly proceeding compilation are removed from here]

    Then, assuming you already have a working /etc/mail/sendmail.cf, you can run a little self-test with the newly created binary,
    but please adjust the path as appropriate for your platform. For example:

    linuxhost:/home/user/src/sendmail-8.13.8$ obj.Linux.2.4.33.i686/sendmail/sendmail -bt -d0.1 < /dev/null 
    Version 8.13.8-subj-logging
     Compiled with: DNSMAP LOG MAP_REGEX MATCHGECOS MILTER MIME7TO8 MIME8TO7
                    NAMED_BIND NETINET NETUNIX NEWDB PIPELINING SCANF STARTTLS
                    USERDB XDEBUG
    
    ============ SYSTEM IDENTITY (after readcf) ============
          (short domain name) $w = mailserver
      (canonical domain name) $j = mailserver.example.com
             (subdomain name) $m = example.com
                  (node name) $k = mailserver
    ========================================================
    
    ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    Enter  

    The purpose of the added configuration option LogSubjectHeader should be self-explanatory. It takes a boolean value (default is True).
    If you want to turn off Subject logging, do not edit your sendmail.cf directly, but add the following to the "source" M4 sendmail.mc.
    define(`confLOG_SUBJECT_HEADER', `False')dnl
    
    Then just rebuild the sendmail.cf and install it as appropriate.

    NOTE: If the envelope has multiple recipients, one log entry similar to this will be emitted for each recipient:

    Sep  3 13:02:48 mailserver sm-mta[5751]: j93A2lEJ005750: msgid=<2.4.33.200630423@example.com>, subject='This is a subject'
    

    The second feature provided by this tiny patch is extremely exotic and it is likely that not many people will ever need it.
    Hence Sendmail does not provide it by default. However, some larger sites may have similar problems as mine did.

    The problem is that certain multiplexing hardware devices and latency checking hosts behave very stupidly
    and it is not always possible to do anything to fix them. They might go through the following sequence periodically:

  • Establish a TCP connection to the MTA (e.g. Sendmail)
  • Send QUIT command and close the TCP connection

    This can quickly lead to many unnecessary log entries like:

    Sep  3 18:17:14 mailserver sm-mta[20899]: j93FHDNX020899: stupid-poller.example.com [xxx.yyy.zzz.www]
    did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
    

    To allow certain known crazy hosts to make these "null connections" without each of them getting logged,
    you can define a class {NullConnOkay} and add desired fully qualified host names into it.
    Hosts in that class do not cause log entries like the one above. I think the cleanest way
    to define such a class is to use an external file in which you enumerate the hosts.
    Add the LOCAL_CONFIG stuff after the MAILER entries in your sendmail.mc.

    For example:

    MAILER(`local')dnl
    MAILER(`smtp')dnl
    LOCAL_CONFIG
    F{NullConnOkay}-o /etc/mail/nullconnects