changeset 4637:0af548f101f8 HEAD

Log all mail saves and save failures.
author Timo Sirainen <tss@iki.fi>
date Sun, 08 Oct 2006 23:09:48 +0300
parents 630e6121fb8d
children 689a02ca02d3
files src/deliver/deliver.c src/deliver/mail-send.c
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/deliver.c	Sun Oct 08 22:24:37 2006 +0300
+++ b/src/deliver/deliver.c	Sun Oct 08 23:09:48 2006 +0300
@@ -11,6 +11,7 @@
 #include "istream-seekable.h"
 #include "module-dir.h"
 #include "str.h"
+#include "str-sanitize.h"
 #include "var-expand.h"
 #include "message-address.h"
 #include "dict-client.h"
@@ -104,6 +105,7 @@
 	struct mailbox *box;
 	struct mailbox_transaction_context *t;
 	struct mail_keywords *kw;
+	const char *msgid;
 	int ret = 0;
 
 	box = mailbox_open_or_create_synced(storage, mailbox);
@@ -123,6 +125,12 @@
 	else
 		ret = mailbox_transaction_commit(&t, 0);
 
+	msgid = mail_get_first_header(mail, "Message-ID");
+	i_info(ret < 0 ? "msgid=%s: save failed to %s" :
+	       "msgid=%s: saved mail to %s",
+	       msgid == NULL ? "" : str_sanitize(msgid, 80),
+	       str_sanitize(mailbox_get_name(box), 80));
+
 	mailbox_close(&box);
 	return ret;
 }
--- a/src/deliver/mail-send.c	Sun Oct 08 22:24:37 2006 +0300
+++ b/src/deliver/mail-send.c	Sun Oct 08 23:09:48 2006 +0300
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "hostpid.h"
 #include "istream.h"
+#include "str-sanitize.h"
 #include "message-date.h"
 #include "message-size.h"
 #include "duplicate.h"
@@ -31,13 +32,16 @@
     struct message_size hdr_size;
     const char *return_addr, *str;
     const unsigned char *data;
-    const char *msgid, *boundary;
+    const char *msgid, *orig_msgid, *boundary;
     size_t size;
     int ret;
 
+    orig_msgid = mail_get_first_header(mail, "Message-ID");
     return_addr = deliver_get_return_address(mail);
     if (return_addr == NULL) {
-	    i_info("Return-Path missing, rejection reason: %s", reason);
+	    i_info("msgid=%s: Return-Path missing, rejection reason: %s",
+		   orig_msgid == NULL ? "" : str_sanitize(orig_msgid, 80),
+		   str_sanitize(reason, 512));
 	    return -1;
     }
 
@@ -80,9 +84,8 @@
 	fprintf(f, "Original-Recipient: rfc822; %s\r\n", str);
     fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
 
-    str = mail_get_first_header(mail, "Message-ID");
-    if (str != NULL)
-	fprintf(f, "Original-Message-ID: %s\r\n", str);
+    if (orig_msgid != NULL)
+	fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid);
     fprintf(f, "Disposition: "
 	    "automatic-action/MDN-sent-automatically; deleted\r\n");
     fprintf(f, "\r\n");