mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
ace425892d
commit
89b4cb75e3
2 changed files with 34 additions and 20 deletions
|
@ -528,24 +528,7 @@ class CakeEmail {
|
|||
);
|
||||
$include += $defaults;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
$relation = array(
|
||||
'from' => 'From',
|
||||
'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']) {
|
||||
$headers['Subject'] = $this->_subject;
|
||||
}
|
||||
|
|
|
@ -240,7 +240,13 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->CakeEmail->setFrom('cake@cakephp.org');
|
||||
$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->CakeEmail->setFrom('cake@cakephp.org', 'CakePHP');
|
||||
|
@ -248,7 +254,14 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertIdentical($this->CakeEmail->getHeaders(array('from' => true)), $expected);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue