Remove port numbers from Message-id domains.

Fixes #3244
This commit is contained in:
mark_story 2012-09-28 21:20:14 -04:00
parent 2d46fc60be
commit 853d866c35
2 changed files with 9 additions and 5 deletions

View file

@ -325,7 +325,7 @@ class CakeEmail {
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');
}

View file

@ -411,14 +411,18 @@ class CakeEmailTest extends CakeTestCase {
* @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']);
}
/**