 # HG changeset patch
-# Parent 0adc48d4d858a9547c4c97935fb3972d5b450600
+# Parent 433268decbc634fd8855bdc114a9356dfec431dd
 # User Sukhbir Singh <sukhbir.in@gmail.com>
 Added support for setting a custom message-ID
 

diff --git a/mailnews/compose/src/nsMsgCompUtils.cpp b/mailnews/compose/src/nsMsgCompUtils.cpp
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -1116,18 +1116,36 @@ msg_generate_message_id (nsIMsgIdentity 
   }
 
   if (!isValidHost(host))

      valid message ID, so bail, and let NNTP and SMTP generate them. */
     return 0;
 
-  GenerateGlobalRandomBytes((unsigned char *) &salt, sizeof(salt));
-  return PR_smprintf("<%lX.%lX@%s>",
-           (unsigned long) now, (unsigned long) salt, host);
+  bool custom_message_id = false;
+  char *message_id = nsnull;
+
+  nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
+  prefs->GetBoolPref("mailnews.custom_message_id", &custom_message_id);
+  prefs->GetCharPref("mailnews.header.custom_message_id", &message_id);
+
+  if (!custom_message_id)
+  {
+    GenerateGlobalRandomBytes((unsigned char *) &salt, sizeof(salt));
+    return PR_smprintf("<%lX.%lX@%s>",
+             (unsigned long) now, (unsigned long) salt, host);
+  }
+  else
+  {
+    return PR_smprintf("<%s@%s>",
+             message_id, host);
+  }
+
 }
