From 8cb245c2787fbcb7786349bfbc2379a51c73f8e6 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 01 Sep 2006 09:53:23 -0400
Subject: [PATCH] Correct creation of a message-id

---
 program/include/main.inc        |   27 +++++++++++++++++++--------
 program/steps/mail/sendmail.inc |    2 +-
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index ecf53b5..9214948 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -519,14 +519,7 @@
 
   if ($user_id = $DB->insert_id(get_sequence_name('users')))
     {
-    $mail_domain = $host;
-    if (is_array($CONFIG['mail_domain']))
-      {
-      if (isset($CONFIG['mail_domain'][$host]))
-        $mail_domain = $CONFIG['mail_domain'][$host];
-      }
-    else if (!empty($CONFIG['mail_domain']))
-      $mail_domain = $CONFIG['mail_domain'];
+    $mail_domain = rcmail_mail_domain($host);
    
     if ($user_email=='')
       $user_email = strstr($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain);
@@ -1646,6 +1639,24 @@
   }
 
 
+// return the mail domain configured for the given host
+function rcmail_mail_domain($host)
+  {
+  global $CONFIG;
+
+  $domain = $host;
+  if (is_array($CONFIG['mail_domain']))
+    {
+    if (isset($CONFIG['mail_domain'][$host]))
+      $domain = $CONFIG['mail_domain'][$host];
+    }
+  else if (!empty($CONFIG['mail_domain']))
+    $domain = $CONFIG['mail_domain'];
+
+  return $domain;
+  }
+
+
 // return code for the webmail login form
 function rcmail_login_form($attrib)
   {
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 30d59db..375fc92 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -66,7 +66,7 @@
 if (strlen($_POST['_draft_saveid']) > 3)
   $olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST);
 
-$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $_SESSION['imap_host']);
+$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host']));
 $savedraft = !empty($_POST['_draft']) ? TRUE : FALSE;
 
 // remove all scripts and act as called in frame

--
Gitblit v1.9.1