Skip to content

Commit

Permalink
Remove port numbers from Message-id domains.
Browse files Browse the repository at this point in the history
Fixes #3244
  • Loading branch information
markstory committed Sep 29, 2012
1 parent 2d46fc6 commit 853d866
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -325,7 +325,7 @@ public function __construct($config = null) {
if ($this->_appCharset !== null) {
$this->charset = $this->_appCharset;
}
$this->_domain = env('HTTP_HOST');
$this->_domain = preg_replace('/\:\d+$/', '', env('HTTP_HOST'));
if (empty($this->_domain)) {
$this->_domain = php_uname('n');
}
Expand Down
12 changes: 8 additions & 4 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -411,14 +411,18 @@ public function testDomain() {
* @return void
*/
public function testMessageIdWithDomain() {
$result = $this->CakeEmail->getHeaders();
$expected = '@' . (env('HTTP_HOST') ? env('HTTP_HOST') : php_uname('n')) . '>';
$this->assertTextContains($expected, $result['Message-ID']);

$this->CakeEmail->domain('example.org');
$result = $this->CakeEmail->getHeaders();
$expected = '@example.org>';
$this->assertTextContains($expected, $result['Message-ID']);

$_SERVER['HTTP_HOST'] = 'example.org';
$result = $this->CakeEmail->getHeaders();
$this->assertTextContains('example.org', $result['Message-ID']);

$_SERVER['HTTP_HOST'] = 'example.org:81';
$result = $this->CakeEmail->getHeaders();
$this->assertTextNotContains(':81', $result['Message-ID']);
}

/**
Expand Down

0 comments on commit 853d866

Please sign in to comment.