Changed to addresses come before others headers. It is not a RFC rule, just to keep more readable the header.

This commit is contained in:
Juan Basso 2011-03-01 21:10:34 -03:00
parent ace425892d
commit 89b4cb75e3
2 changed files with 34 additions and 20 deletions

View file

@ -528,24 +528,7 @@ class CakeEmail {
); );
$include += $defaults; $include += $defaults;
$headers = $this->_headers; $headers = array();
if (!isset($headers['X-Mailer'])) {
$headers['X-Mailer'] = Configure::read('Email.XMailer');
if (empty($headers['X-Mailer'])) {
$headers['X-Mailer'] = self::EMAIL_CLIENT;
}
}
if (!isset($headers['Date'])) {
$headers['Date'] = date(DATE_RFC2822);
}
if ($this->_messageId !== false) {
if ($this->_messageId === true) {
$headers['Message-ID'] = '<' . String::UUID() . '@' . env('HTTP_HOST') . '>';
} else {
$headers['Message-ID'] = $this->_messageId;
}
}
$relation = array( $relation = array(
'from' => 'From', 'from' => 'From',
'replyTo' => 'Reply-To', 'replyTo' => 'Reply-To',
@ -566,6 +549,24 @@ class CakeEmail {
} }
} }
$headers += $this->_headers;
if (!isset($headers['X-Mailer'])) {
$headers['X-Mailer'] = Configure::read('Email.XMailer');
if (empty($headers['X-Mailer'])) {
$headers['X-Mailer'] = self::EMAIL_CLIENT;
}
}
if (!isset($headers['Date'])) {
$headers['Date'] = date(DATE_RFC2822);
}
if ($this->_messageId !== false) {
if ($this->_messageId === true) {
$headers['Message-ID'] = '<' . String::UUID() . '@' . env('HTTP_HOST') . '>';
} else {
$headers['Message-ID'] = $this->_messageId;
}
}
if ($include['subject']) { if ($include['subject']) {
$headers['Subject'] = $this->_subject; $headers['Subject'] = $this->_subject;
} }

View file

@ -240,7 +240,13 @@ class CakeEmailTest extends CakeTestCase {
$this->CakeEmail->setFrom('cake@cakephp.org'); $this->CakeEmail->setFrom('cake@cakephp.org');
$this->assertIdentical($this->CakeEmail->getHeaders(), $expected); $this->assertIdentical($this->CakeEmail->getHeaders(), $expected);
$expected['From'] = 'cake@cakephp.org'; $expected = array(
'From' => 'cake@cakephp.org',
'X-Something' => 'very nice',
'X-Other' => 'cool',
'X-Mailer' => 'CakePHP Email Component',
'Date' => date(DATE_RFC2822)
);
$this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true)), $expected); $this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true)), $expected);
$this->CakeEmail->setFrom('cake@cakephp.org', 'CakePHP'); $this->CakeEmail->setFrom('cake@cakephp.org', 'CakePHP');
@ -248,7 +254,14 @@ class CakeEmailTest extends CakeTestCase {
$this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true)), $expected); $this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true)), $expected);
$this->CakeEmail->setTo(array('cake@cakephp.org', 'php@cakephp.org' => 'CakePHP')); $this->CakeEmail->setTo(array('cake@cakephp.org', 'php@cakephp.org' => 'CakePHP'));
$expected['To'] = 'cake@cakephp.org, CakePHP <php@cakephp.org>'; $expected = array(
'From' => 'CakePHP <cake@cakephp.org>',
'To' => 'cake@cakephp.org, CakePHP <php@cakephp.org>',
'X-Something' => 'very nice',
'X-Other' => 'cool',
'X-Mailer' => 'CakePHP Email Component',
'Date' => date(DATE_RFC2822)
);
$this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true, 'to' => true)), $expected); $this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true, 'to' => true)), $expected);
} }