|
|
@@ -1168,6 +1168,48 @@ class CakeEmailTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test setting inline attachments and HTML only messages.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSendWithInlineAttachmentsHtmlOnly() {
|
|
|
+ $this->CakeEmail->transport('debug');
|
|
|
+ $this->CakeEmail->from('cake@cakephp.org');
|
|
|
+ $this->CakeEmail->to('cake@cakephp.org');
|
|
|
+ $this->CakeEmail->subject('My title');
|
|
|
+ $this->CakeEmail->emailFormat('html');
|
|
|
+ $this->CakeEmail->attachments(array(
|
|
|
+ 'cake.png' => array(
|
|
|
+ 'file' => CAKE . 'VERSION.txt',
|
|
|
+ 'contentId' => 'abc123'
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ $result = $this->CakeEmail->send('Hello');
|
|
|
+
|
|
|
+ $boundary = $this->CakeEmail->getBoundary();
|
|
|
+ $this->assertContains('Content-Type: multipart/mixed; boundary="' . $boundary . '"', $result['headers']);
|
|
|
+ $expected = "--$boundary\r\n" .
|
|
|
+ "Content-Type: multipart/related; boundary=\"rel-$boundary\"\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "--rel-$boundary\r\n" .
|
|
|
+ "Content-Type: text/html; charset=UTF-8\r\n" .
|
|
|
+ "Content-Transfer-Encoding: 8bit\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "Hello" .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "--rel-$boundary\r\n" .
|
|
|
+ "Content-Type: application/octet-stream\r\n" .
|
|
|
+ "Content-Transfer-Encoding: base64\r\n" .
|
|
|
+ "Content-ID: <abc123>\r\n" .
|
|
|
+ "Content-Disposition: inline; filename=\"cake.png\"\r\n\r\n";
|
|
|
+ $this->assertContains($expected, $result['message']);
|
|
|
+ $this->assertContains('--rel-' . $boundary . '--', $result['message']);
|
|
|
+ $this->assertContains('--' . $boundary . '--', $result['message']);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Test disabling content-disposition.
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -1302,6 +1344,52 @@ class CakeEmailTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * testSendRender both method
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSendRenderBoth() {
|
|
|
+ $this->CakeEmail->reset();
|
|
|
+ $this->CakeEmail->transport('debug');
|
|
|
+
|
|
|
+ $this->CakeEmail->from('cake@cakephp.org');
|
|
|
+ $this->CakeEmail->to(array('you@cakephp.org' => 'You'));
|
|
|
+ $this->CakeEmail->subject('My title');
|
|
|
+ $this->CakeEmail->config(array('empty'));
|
|
|
+ $this->CakeEmail->template('default', 'default');
|
|
|
+ $this->CakeEmail->emailFormat('both');
|
|
|
+ $result = $this->CakeEmail->send();
|
|
|
+
|
|
|
+ $this->assertContains('Message-ID: ', $result['headers']);
|
|
|
+ $this->assertContains('To: ', $result['headers']);
|
|
|
+
|
|
|
+ $boundary = $this->CakeEmail->getBoundary();
|
|
|
+ $this->assertContains('Content-Type: multipart/alternative; boundary="' . $boundary . '"', $result['headers']);
|
|
|
+
|
|
|
+ $expected = "--$boundary\r\n" .
|
|
|
+ "Content-Type: text/plain; charset=UTF-8\r\n" .
|
|
|
+ "Content-Transfer-Encoding: 8bit\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "This email was sent using the CakePHP Framework, http://cakephp.org." .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "--$boundary\r\n" .
|
|
|
+ "Content-Type: text/html; charset=UTF-8\r\n" .
|
|
|
+ "Content-Transfer-Encoding: 8bit\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "<!DOCTYPE html";
|
|
|
+ $this->assertStringStartsWith($expected, $result['message']);
|
|
|
+
|
|
|
+ $expected = "</html>\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "\r\n" .
|
|
|
+ "--$boundary--\r\n";
|
|
|
+ $this->assertStringEndsWith($expected, $result['message']);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* testSendRender method for ISO-2022-JP
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -1542,8 +1630,6 @@ class CakeEmailTest extends CakeTestCase {
|
|
|
$this->assertFalse(empty($boundary));
|
|
|
$this->assertContains('--' . $boundary, $message);
|
|
|
$this->assertContains('--' . $boundary . '--', $message);
|
|
|
- $this->assertContains('--alt-' . $boundary, $message);
|
|
|
- $this->assertContains('--alt-' . $boundary . '--', $message);
|
|
|
|
|
|
$this->CakeEmail->attachments(array('fake.php' => __FILE__));
|
|
|
$this->CakeEmail->send();
|
|
|
@@ -2005,7 +2091,7 @@ class CakeEmailTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
protected function _checkContentTransferEncoding($message, $charset) {
|
|
|
- $boundary = '--alt-' . $this->CakeEmail->getBoundary();
|
|
|
+ $boundary = '--' . $this->CakeEmail->getBoundary();
|
|
|
$result['text'] = false;
|
|
|
$result['html'] = false;
|
|
|
$length = count($message);
|