I had a need for spamd to log the SMTP msg id when it logs 'clean message' or 'identified spam' to the syslog. Below is a patch to spamd.raw (2.63) that adds a --log-msg-id option. Normally a log message would look like

Mar 1 17:23:19 hostname spamd[26805]: identified spam (66.7/4.9) for spamuser:702 in 1.4 seconds, 1217 bytes.

but with the --log-msg-id option on, it looks like this:

Mar 1 17:23:19 hostname spamd[26805]: identified spam <[EMAIL PROTECTED]> (66.7/4.9) for spamuser:702 in 1.4 seconds, 1217 bytes.

To me, it seems like the msg id should always be there, since it's there when spamd announces that it's working on a message. But I didn't want to break anything, so it's an option. :-)

Steve Abatangle
E-Loan, Inc.


--- spamd.raw.orig Mon Mar 1 16:34:54 2004 +++ spamd.raw Mon Mar 1 17:04:13 2004 @@ -122,6 +122,7 @@ 'pidfile|r=s' => \$opt{'pidfile'}, 'syslog|s=s' => \$opt{'syslog'}, 'syslog-socket=s' => \$opt{'syslog-socket'}, + 'log-msg-id' => \$opt{'log-msg-id'}, 'username|u=s' => \$opt{'username'}, 'vpopmail!' => \$opt{'vpopmail'}, 'v' => \$opt{'vpopmail'}, @@ -820,6 +821,7 @@ } }

+    $opt{'log-msg-id'} and $was_it_spam .= " $msgid";
    logmsg "$was_it_spam ($msg_score/$msg_threshold) for $current_user:$> in ".
        sprintf("%.1f", time - $start) ." seconds, $actual_length bytes.";

@@ -1374,6 +1376,8 @@
 -r pidfile, --pidfile              Write the process id to pidfile
 -s facility, --syslog=facility     Specify the syslog facility (default: mail)
 --syslog-socket=type               How to connect to syslogd (default: unix)
+ --log-msg-id                       Write SMTP message id in syslog when 
reporting
+                                    results of spam check
 -u username, --username=username   Run as username
 -v, --vpopmail                     Enable vpopmail config
 -x, --nouser-config                Disable user config files
@@ -1577,6 +1581,13 @@
need to set this.  If you get error messages regarding B<__PATH_LOG> or similar
from spamd, try changing this setting.

+=item B<--log-msg-id>
+
+Write SMTP message id in syslog when reporting results of spam check. Normally,
+C<spamd> logs only whether the message was clean or identified as spam. This
+option will add the SMTP message id, which can help you if you want to analyze
+mail log statistics (clean vs. spam messages, etc.).
+
=item B<-u> I<username>, B<--username>=I<username>

Run as the named user.  If this option is not set, the default behaviour





Reply via email to