Skip to content

Commit

Permalink
Fix bug where Message-ID domain part was tied to username instead of …
Browse files Browse the repository at this point in the history
…current identity (#5385)
  • Loading branch information
alecpl committed Aug 9, 2016
1 parent 2fb8254 commit c2b4414
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG Roundcube Webmail
- Use SymLinksIfOwnerMatch in .htaccess instead of FollowSymLinks disabled on some hosts for security reasons (#5370)
- Wash position:fixed style in HTML mail for better security (#5264)
- Fix bug where memcache_debug didn't work for session operations
- Fix bug where Message-ID domain part was tied to username instead of current identity (#5385)

RELEASE 1.2.1
-------------
Expand Down
15 changes: 12 additions & 3 deletions program/lib/Roundcube/rcube.php
Original file line number Diff line number Diff line change
Expand Up @@ -1488,15 +1488,24 @@ public function get_user_language()
/**
* Unique Message-ID generator.
*
* @param string $sender Optional sender e-mail address
*
* @return string Message-ID
*/
public function gen_message_id()
public function gen_message_id($sender = null)
{
$local_part = md5(uniqid('rcube'.mt_rand(), true));
$domain_part = $this->user->get_username('domain');
$domain_part = '';

if ($sender && preg_match('/@([^\s]+\.[a-z0-9-]+)/', $sender, $m)) {
$domain_part = $m[1];
}
else {
$domain_part = $this->user->get_username('domain');
}

// Try to find FQDN, some spamfilters doesn't like 'localhost' (#1486924)
if (!preg_match('/\.[a-z]+$/i', $domain_part)) {
if (!preg_match('/\.[a-z0-9-]+$/i', $domain_part)) {
foreach (array($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME']) as $host) {
$host = preg_replace('/:[0-9]+$/', '', $host);
if ($host && preg_match('/\.[a-z]+$/i', $host)) {
Expand Down
2 changes: 1 addition & 1 deletion program/steps/mail/func.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1826,7 +1826,7 @@ function rcmail_send_mdn($message, &$smtp_error)
'From' => $sender,
'To' => $message->headers->mdn_to,
'Subject' => $RCMAIL->gettext('receiptread') . ': ' . $message->subject,
'Message-ID' => $RCMAIL->gen_message_id(),
'Message-ID' => $RCMAIL->gen_message_id($identity['email']),
'X-Sender' => $identity['email'],
'References' => trim($message->headers->references . ' ' . $message->headers->messageID),
'In-Reply-To' => $message->headers->messageID,
Expand Down
10 changes: 5 additions & 5 deletions program/steps/mail/sendmail.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ if (!$savedraft) {

/****** compose message ********/

if (empty($COMPOSE['param']['message-id'])) {
$COMPOSE['param']['message-id'] = $RCMAIL->gen_message_id();
}
$message_id = $COMPOSE['param']['message-id'];

// set default charset
$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $OUTPUT->get_charset();

Expand Down Expand Up @@ -123,6 +118,11 @@ if (!$from_string && $from) {
$from_string = $from;
}

if (empty($COMPOSE['param']['message-id'])) {
$COMPOSE['param']['message-id'] = $RCMAIL->gen_message_id($from);
}
$message_id = $COMPOSE['param']['message-id'];

// compose headers array
$headers = array();

Expand Down

0 comments on commit c2b4414

Please sign in to comment.