Skip to content

Commit

Permalink
Allowing strings in cc and bcc. Fixes #1553.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Feb 23, 2011
1 parent 21a9904 commit 52163b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions cake/libs/controller/components/email.php
Expand Up @@ -561,11 +561,7 @@ function _createHeader() {
$headers = array();

if ($this->delivery == 'smtp') {
if (is_array($this->to)) {
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to));
} else {
$headers['To'] = $this->_formatAddress($this->to);
}
$headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to));
}
$headers['From'] = $this->_formatAddress($this->from);

Expand All @@ -580,11 +576,11 @@ function _createHeader() {
}

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

if (!empty($this->bcc) && $this->delivery != 'smtp') {
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc));
$headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc));
}
if ($this->delivery == 'smtp') {
$headers['Subject'] = $this->_encode($this->subject);
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/controller/components/email.test.php
Expand Up @@ -740,6 +740,8 @@ function testSmtpSendSocket() {
function testSendDebug() {
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->cc = 'cc@example.com';
$this->Controller->EmailTest->bcc = 'bcc@example.com';
$this->Controller->EmailTest->subject = 'Cake Debug Test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
Expand All @@ -752,6 +754,8 @@ function testSendDebug() {
$this->assertPattern('/Subject: Cake Debug Test\n/', $result);
$this->assertPattern('/Reply-To: noreply@example.com\n/', $result);
$this->assertPattern('/From: noreply@example.com\n/', $result);
$this->assertPattern('/Cc: cc@example.com\n/', $result);
$this->assertPattern('/Bcc: bcc@example.com\n/', $result);
$this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result);
$this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
Expand Down

0 comments on commit 52163b4

Please sign in to comment.