diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 12:08:41 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 12:08:41 +0000 |
| commit | 6b2489f4d71ab823b1ab1b4e54fae7cd377ac53d (patch) | |
| tree | a6aea3a03712705984ce66e4ba3de216fdcc69b6 | |
| parent | b850600c73fe8da5f1c8aaa0b31140c43dd348e8 (diff) | |
- Use host FQDN in Message-Id, if possible (#1486924)
git-svn-id: https://svn.roundcube.net/trunk@3923 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | roundcubemail/program/steps/mail/func.inc | 25 | ||||
| -rw-r--r-- | roundcubemail/program/steps/mail/sendmail.inc | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc index 1509f9028..73d675a60 100644 --- a/roundcubemail/program/steps/mail/func.inc +++ b/roundcubemail/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() { diff --git a/roundcubemail/program/steps/mail/sendmail.inc b/roundcubemail/program/steps/mail/sendmail.inc index 300bea019..23ff571b2 100644 --- a/roundcubemail/program/steps/mail/sendmail.inc +++ b/roundcubemail/program/steps/mail/sendmail.inc @@ -205,7 +205,7 @@ function rcmail_email_input_format($mailto, $count=false) if (strlen($_POST['_draft_saveid']) > 3) $olddraftmessageid = get_input_value('_draft_saveid', RCUBE_INPUT_POST); -$message_id = sprintf('<%s@%s>', md5(uniqid('rcmail'.mt_rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])); +$message_id = rcmail_gen_message_id(); // set default charset $input_charset = $OUTPUT->get_charset(); |
