[Exim] Logging the envelope sender for remote deliveries and…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Theo E. Schlossnagle
Dátum:  
Címzett: exim-users
Tárgy: [Exim] Logging the envelope sender for remote deliveries and faulures. [patch]
This message is to Philip and developers.

I didn't see a development list :-(

For a bounce processing system I am working on it is extremely useful to know
who sent the message when it is delivered or hard fails. Of course, exim
knows this but it doesn't share this secret in the log file.

I have addeded E=<sender_address> (E is for Envelope Sender) as a logging
extension for remote deliveries and hard failures. And a configuration
options (a long one) to enable it. By default it is false and doesn't change
the way exim logs now unless you specify:

log_envelope_sender_on_remote_delivery = true

The motivation:

We send out mails and like most large mailing operations we tag the return
path (or envelope sender) with a piece of user identifying data to process
bounces and track deliveries effectively. (e.g.
bounces-userid@???). If we want to mark a user as bounced or
successfully delivered, we need to mark it in the database based on the user's
ID. We handle soft bounces in a completely separate system.

On the hosts that are sending the messages out, it is much much faster to
_not_ deliver the errors. Instead you use errors_to or deliver the
bounce-*@??? to :blackhole:. You pick up the bounce
information either in real-time or after the fact from the mail logs.

Before this "feature" you needed to marry up the queueid during delivery or
failure to the queueid of the inbound message. Only then could you see who
the envelope sender is. This can be annoying at the very least. Keeping
track of this can be resource intensive and an overall pain.

With the E=<sender_address> in the log line for those deliveries/failure, you
immediately have enough information to act on. (e.g. update a database row).

The patch (pretty small):

diff -u exim-3.22/src/deliver.c exim-3.22/src.lesord/deliver.c
--- exim-3.22/src/deliver.c     Fri Jan 19 04:31:45 2001
+++ exim-3.22/src.lesord/deliver.c      Sun Feb 11 14:52:26 2001
@@ -770,6 +770,12 @@
       }
     }


+    if(log_envelope_sender_on_remote_delivery)
+      if(sender_address)
+        s = mac_cat2(s, &size, &ptr, " E=", sender_address);
+      else
+        s = mac_cat2(s, &size, &ptr, " E=", "<>");
+
   /* string_cat() always leaves room for the terminator. Release the
   store we used to build the line after writing it. */


@@ -973,6 +979,12 @@
     fprintf(message_log, "%s %s\n", now, s);


   fflush(message_log);
+
+  if(log_envelope_sender_on_remote_delivery)
+    if(sender_address)
+      s = mac_cat2(s, &size, &ptr, " E=", sender_address);
+    else
+      s = mac_cat2(s, &size, &ptr, " E=", "<>");


   log_write(0, LOG_MAIN, "** %s", s);
   store_reset(reset_point);
diff -u exim-3.22/src/globals.c exim-3.22/src.lesord/globals.c
--- exim-3.22/src/globals.c     Fri Jan 19 04:31:46 2001
+++ exim-3.22/src.lesord/globals.c      Sun Feb 11 14:46:22 2001
@@ -410,6 +410,7 @@
 BOOL   log_all_parents        = FALSE;
 BOOL   log_arguments          = FALSE;
 char  *log_buffer             = NULL;
+BOOL   log_envelope_sender_on_remote_delivery = FALSE;
 char  *log_file_path          = LOG_FILE_PATH
                          "\0<--------------Space to patch log_file_path->";
 BOOL   log_incoming_port      = FALSE;
diff -u exim-3.22/src/globals.h exim-3.22/src.lesord/globals.h
--- exim-3.22/src/globals.h     Fri Jan 19 04:31:46 2001
+++ exim-3.22/src.lesord/globals.h      Sun Feb 11 14:46:35 2001
@@ -282,6 +282,7 @@
 extern BOOL   log_all_parents;        /* As it says */
 extern BOOL   log_arguments;          /* Logs Exim's args */
 extern char  *log_buffer;             /* For constructing log entries */
+extern BOOL   log_envelope_sender_on_remote_delivery; /* Log E=sender_address
on remote deliveries */
 extern char  *log_file_path;          /* If unset, use default */
 extern BOOL   log_incoming_port;      /* For logging incoming port numbers */
 extern BOOL   log_ip_options;         /* For logging IP source routing */
diff -u exim-3.22/src/readconf.c exim-3.22/src.lesord/readconf.c
--- exim-3.22/src/readconf.c    Fri Jan 19 04:31:48 2001
+++ exim-3.22/src.lesord/readconf.c     Sun Feb 11 14:46:08 2001
@@ -120,6 +120,7 @@
   { "locally_caseless",         opt_bool,        &locally_caseless },
   { "log_all_parents",          opt_bool,        &log_all_parents },
   { "log_arguments",            opt_bool,        &log_arguments },
+  { "log_envelope_sender_on_remote_delivery", opt_bool,
&log_envelope_sender_on_remote_delivery },
   { "log_file_path",            opt_stringptr,   &log_file_path },
   { "log_incoming_port",        opt_bool,        &log_incoming_port },
   { "log_ip_options",           opt_bool,        &log_ip_options },



--
Theo Schlossnagle
1024D/A8EBCF8F/13BD 8C08 6BE2 629A 527E 2DC2 72C2 AD05 A8EB CF8F
2047R/33131B65/71 F7 95 64 49 76 5D BA 3D 90 B9 9F BE 27 24 E7