Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes #6397, removing unneeded line feed in email component headers, …

…adding tests

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8248 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 3e14d281dfe3fe0e361d91af39740824ea690351 1 parent 07096f3
@tim-kos tim-kos authored
View
3  cake/libs/controller/components/email.php
@@ -491,7 +491,6 @@ function __createHeader() {
$this->__header[] = 'Content-Type: text/html; charset=' . $this->charset;
} elseif ($this->sendAs === 'both') {
$this->__header[] = 'Content-Type: multipart/alternative; boundary="alt-' . $this->__boundary . '"';
- $this->__header[] = '';
}
$this->__header[] = 'Content-Transfer-Encoding: 7bit';
@@ -504,7 +503,7 @@ function __createHeader() {
*/
function __formatMessage($message) {
if (!empty($this->attachments)) {
- $prefix[] = '--' . $this->__boundary;
+ $prefix = array('--' . $this->__boundary);
if ($this->sendAs === 'text') {
$prefix[] = 'Content-Type: text/plain; charset=' . $this->charset;
} elseif ($this->sendAs === 'html') {
View
30 cake/tests/cases/libs/controller/components/email.test.php
@@ -337,7 +337,8 @@ function testSendFormats() {
// TODO: better test for format of message sent?
$this->Controller->EmailTest->sendAs = 'both';
- $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $message);
+ $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"', $message);
+
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
@@ -412,10 +413,11 @@ function testTemplates() {
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
$this->Controller->EmailTest->sendAs = 'both';
- $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $header);
+ $expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"', $header);
$expect .= '--alt-' . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n";
$expect .= '--alt-' . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n";
$expect = '<pre>' . $expect . '--alt---' . "\n\n" . '</pre>';
+
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
@@ -588,11 +590,35 @@ function testSendAsIsNotIgnoredIfAttachmentsPresent() {
$this->Controller->EmailTest->sendAs = 'both';
$this->assertTrue($this->Controller->EmailTest->send($body));
$msg = $this->Controller->Session->read('Message.email.message');
+
$this->assertNoPattern('/text\/plain/', $msg);
$this->assertNoPattern('/text\/html/', $msg);
$this->assertPattern('/multipart\/alternative/', $msg);
}
/**
+ * undocumented function
+ *
+ * @return void
+ * @access public
+ */
+ function testNoDoubleNewlinesInHeaders() {
+ $this->Controller->EmailTest->reset();
+ $this->Controller->EmailTest->to = 'postmaster@localhost';
+ $this->Controller->EmailTest->from = 'noreply@example.com';
+ $this->Controller->EmailTest->subject = 'Attachment Test';
+ $this->Controller->EmailTest->replyTo = 'noreply@example.com';
+ $this->Controller->EmailTest->template = null;
+ $this->Controller->EmailTest->delivery = 'debug';
+ $body = '<p>This is the body of the message</p>';
+
+ $this->Controller->EmailTest->sendAs = 'both';
+ $this->assertTrue($this->Controller->EmailTest->send($body));
+ $msg = $this->Controller->Session->read('Message.email.message');
+
+ $this->assertNoPattern('/\n\nContent-Transfer-Encoding/', $msg);
+ $this->assertPattern('/\nContent-Transfer-Encoding/', $msg);
+ }
+/**
* testReset method
*
* @access public
Please sign in to comment.
Something went wrong with that request. Please try again.