Skip to content

Commit 52163b4

Browse files
committed
Allowing strings in cc and bcc. Fixes #1553.
1 parent 21a9904 commit 52163b4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

cake/libs/controller/components/email.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,7 @@ function _createHeader() {
561561
$headers = array();
562562

563563
if ($this->delivery == 'smtp') {
564-
if (is_array($this->to)) {
565-
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
566-
} else {
567-
$headers['To'] = $this->_formatAddress($this->to);
568-
}
564+
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to));
569565
}
570566
$headers['From'] = $this->_formatAddress($this->from);
571567

@@ -580,11 +576,11 @@ function _createHeader() {
580576
}
581577

582578
if (!empty($this->cc)) {
583-
$headers['cc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->cc));
579+
$headers['Cc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->cc));
584580
}
585581

586582
if (!empty($this->bcc) && $this->delivery != 'smtp') {
587-
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc));
583+
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc));
588584
}
589585
if ($this->delivery == 'smtp') {
590586
$headers['Subject'] = $this->_encode($this->subject);

cake/tests/cases/libs/controller/components/email.test.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,8 @@ function testSmtpSendSocket() {
740740
function testSendDebug() {
741741
$this->Controller->EmailTest->to = 'postmaster@localhost';
742742
$this->Controller->EmailTest->from = 'noreply@example.com';
743+
$this->Controller->EmailTest->cc = 'cc@example.com';
744+
$this->Controller->EmailTest->bcc = 'bcc@example.com';
743745
$this->Controller->EmailTest->subject = 'Cake Debug Test';
744746
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
745747
$this->Controller->EmailTest->template = null;
@@ -752,6 +754,8 @@ function testSendDebug() {
752754
$this->assertPattern('/Subject: Cake Debug Test\n/', $result);
753755
$this->assertPattern('/Reply-To: noreply@example.com\n/', $result);
754756
$this->assertPattern('/From: noreply@example.com\n/', $result);
757+
$this->assertPattern('/Cc: cc@example.com\n/', $result);
758+
$this->assertPattern('/Bcc: bcc@example.com\n/', $result);
755759
$this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result);
756760
$this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result);
757761
$this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result);

0 commit comments

Comments
 (0)