<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Generate Message-IDs from sender address



Hi all,

I have several accounts that end up in one mailbox, and when
replying to messages I usually set the "From:" address so I'm
replying from whatever address the original message was sent to.
While this changes the sender, I noticed that my Message-IDs
always contain inauspicious.org regardless of the domain I'm
sending from, so I wrote this little patch to make it take the
domain part of the Message-ID from the sender address.  I don't
know if this is useful for anyone else, but if it is then have
it :)  It's based on 1.4.2.1 but it seems to work on the latest
CVS too.

Cheers,
Gary
--- mutt-1.4.2.1/protos.h.msgid 2002-04-29 18:12:18.000000000 +0100
+++ mutt-1.4.2.1/protos.h       2006-09-26 11:05:32.000000000 +0100
@@ -125,7 +125,7 @@
 char *_mutt_expand_path (char *, size_t, int);
 char *mutt_find_hook (int, const char *);
 char *mutt_gecos_name (char *, size_t, struct passwd *);
-char *mutt_gen_msgid (void);
+char *mutt_gen_msgid (const char *fqdn);
 char *mutt_get_body_charset (char *, size_t, BODY *);
 char *mutt_get_name (ADDRESS *);
 char *mutt_get_parameter (const char *, PARAMETER *);
--- mutt-1.4.2.1/sendlib.c.msgid        2002-05-31 17:59:39.000000000 +0100
+++ mutt-1.4.2.1/sendlib.c      2006-09-26 11:12:13.000000000 +0100
@@ -1738,16 +1738,17 @@
   return p;
 }
 
-char *mutt_gen_msgid (void)
+char *mutt_gen_msgid (const char *fqdn)
 {
   char buf[SHORT_STRING];
   time_t now;
   struct tm *tm;
-  const char *fqdn;
 
   now = time (NULL);
   tm = gmtime (&now);
-  if(!(fqdn = mutt_fqdn(0)))
+  if(!fqdn)
+    fqdn = mutt_fqdn(0);
+  if(!fqdn)
     fqdn = NONULL(Hostname);
 
   snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%d@%s>",
@@ -2137,7 +2138,19 @@
     mutt_set_followup_to (env);
 
     if (!env->message_id)
-      env->message_id = mutt_gen_msgid ();
+    {
+      char *fqdn = NULL;
+
+      if (env->from && env->from->mailbox)
+      {
+       fqdn = strrchr (env->from->mailbox, '@');
+
+       if (fqdn)
+         fqdn++;
+      }
+
+      env->message_id = mutt_gen_msgid (fqdn);
+    }
   }
 
   /* Take care of 8-bit => 7-bit conversion. */