summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-08-30 12:08:41 +0000
committeralecpl <alec@alec.pl>2010-08-30 12:08:41 +0000
commit1d8cbca2720171a2f0fe07ec7f34a5c637fae38e (patch)
treea5b76ab393f65d1a6c6bd38086ce35fd6ac6968f /program/steps/mail/func.inc
parent01538da5801d425e32121865a0bcbb28c539aa81 (diff)
- Use host FQDN in Message-Id, if possible (#1486924)
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc25
1 files changed, 24 insertions, 1 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 1509f9028..73d675a60 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1544,7 +1544,7 @@ function rcmail_send_mdn($uid, &$smtp_error)
'From' => $sender,
'To' => $message->headers->mdn_to,
'Subject' => rcube_label('receiptread') . ': ' . $message->subject,
- 'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.mt_rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])),
+ 'Message-ID' => rcmail_gen_message_id(),
'X-Sender' => $identity['email'],
'References' => trim($message->headers->references . ' ' . $message->headers->messageID),
);
@@ -1585,6 +1585,29 @@ function rcmail_send_mdn($uid, &$smtp_error)
return false;
}
+// Returns unique Message-ID
+function rcmail_gen_message_id()
+{
+ global $RCMAIL;
+
+ $local_part = md5(uniqid('rcmail'.mt_rand(),true));
+ $domain_part = $RCMAIL->user->get_username('domain');
+
+ // Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924)
+ if (!preg_match('/\.[a-z]+$/i', $domain_part)) {
+ if (($host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']))
+ && preg_match('/\.[a-z]+$/i', $host)) {
+ $domain_part = $host;
+ }
+ else if (($host = preg_replace('/:[0-9]+$/', '', $_SERVER['SERVER_NAME']))
+ && preg_match('/\.[a-z]+$/i', $host)) {
+ $domain_part = $host;
+ }
+ }
+
+ return sprintf('<%s@%s>', $local_part, $domain_part);
+}
+
// Returns RFC2822 formatted current date in user's timezone
function rcmail_user_date()
{