<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Moved viewer code to horde/Mime_Viewer package.
+ <notes>* Converted tests to PHPUnit.
+ * Moved viewer code to horde/Mime_Viewer package.
* Removed Webcpp and Enscript viewers. Source code highlighting is now
exclusively handled by the Srchighlight driver.
* No need to generate Content-Transfer-Encoding header if part data is 7bit.
<dir name="Mime">
<dir name="fixtures">
<file name="attachment.bin" role="test" />
- <file name="bug_325.txt" role="test" />
+ <file name="flowed_msg.txt" role="test" />
<file name="sample_msg.txt" role="test" />
<file name="uudecode.txt" role="test" />
</dir> <!-- /test/Horde/Mime/fixtures -->
<file name="AddressTest.php" role="test" />
<file name="AllTests.php" role="test" />
<file name="MagicTest.php" role="test" />
+ <file name="MailTest.php" role="test" />
<file name="MimeTest.php" role="test" />
<file name="PartTest.php" role="test" />
- <file name="mail_001.phpt" role="test" />
- <file name="mail_002.phpt" role="test" />
- <file name="mail_003.phpt" role="test" />
- <file name="mail_004.phpt" role="test" />
- <file name="mail_005.phpt" role="test" />
- <file name="mail_006.phpt" role="test" />
- <file name="mail_007.phpt" role="test" />
- <file name="mail_008.phpt" role="test" />
- <file name="mail_dummy.inc" role="test" />
</dir> <!-- /test/Horde/Mime -->
</dir> <!-- /test/Horde -->
</dir> <!-- /test -->
$this->assertEquals(
'text/plain',
- Horde_Mime_Magic::analyzeFile(dirname(__FILE__) . '/fixtures/bug_325.txt')
+ Horde_Mime_Magic::analyzeFile(dirname(__FILE__) . '/fixtures/flowed_msg.txt')
);
}
--- /dev/null
+<?php
+/**
+ * Tests for the Horde_Mime_Mail class.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime
+ * @subpackage UnitTests
+ */
+
+/**
+ * @author Michael Slusarz <slusarz@curecanti.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime
+ * @subpackage UnitTests
+ */
+class Horde_Mime_MailTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $_SERVER['SERVER_NAME'] = 'mail.example.com';
+ }
+
+ public function testConstructor()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'body' => "This is\nthe body",
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-15'
+ ));
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+ "This is\nthe body",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testMethods()
+ {
+ $mail = new Horde_Mime_Mail();
+ $mail->addHeader('Subject', 'My Subject');
+ $mail->setBody("This is\nthe body", 'iso-8859-15');
+ $mail->addHeader('To', 'recipient@example.com');
+ $mail->addHeader('Cc', 'null@example.com');
+ $mail->addHeader('Bcc', 'invisible@example.com');
+ $mail->addHeader('From', 'sender@example.com');
+ $mail->removeHeader('Cc');
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+ "This is\nthe body",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testEncoding()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'Schöner Betreff',
+ 'body' => "Hübsche Umlaute \n und Leerzeichen.",
+ 'to' => 'Empfänger <recipient@example.com>',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-1'
+ ));
+ $mail->addHeader('Cc', 'Der schöne Peter <peter@example.com>', 'iso-8859-15');
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: =?iso-8859-1?b?U2No9m5lcg==?= Betreff
+To: =?iso-8859-1?b?RW1wZuRuZ2Vy?= <recipient@example.com>
+From: sender@example.com
+Cc: Der =?iso-8859-15?b?c2No9m5l?= Peter <peter@example.com>
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
+MIME-Version: 1.0
+Content-Transfer-Encoding: quoted-printable',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+ "H=FCbsche Umlaute\n und Leerzeichen.",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testAddPart()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'body' => "This is\nthe body",
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-15'
+ ));
+ $mail->addPart(
+ 'text/plain',
+ 'This is a plain text',
+ 'iso-8859-1',
+ 'inline'
+ );
+ $mail->addPart(
+ 'application/octet-stream',
+ file_get_contents(dirname(__FILE__) . '/fixtures/attachment.bin'),
+ null,
+ 'attachment'
+ );
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: multipart/mixed; boundary="=_%s"
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+"This message is in MIME format.
+
+--=_%s
+Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
+
+This is
+the body
+
+--=_%s
+Content-Type: text/plain; charset=iso-8859-1
+Content-Disposition: inline
+
+This is a plain text
+--=_%s
+Content-Type: application/octet-stream
+Content-Disposition: attachment
+Content-Transfer-Encoding: base64
+
+WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5
+bHRlciBEZWljaC4K
+--=_%s--",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function addHtmlTest()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com'
+ ));
+ $mail->setBody("This is\nthe plain text body.");
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+ "This is\nthe plain text body.",
+ $dummy->sentMessages[0]['body']
+ );
+
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com'
+ ));
+ $mail->setHTMLBody(
+ "<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>",
+ 'iso-8859-1',
+ false
+ );
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/html; charset=iso-8859-1
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+ "<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>",
+ $dummy->sentMessages[0]['body']
+ );
+
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com'
+ ));
+ $mail->setHTMLBody("<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>");
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: multipart/alternative; boundary="=_%s"
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+"This message is in MIME format.
+
+--=_%s
+Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
+Content-Description: Plaintext Version of Message
+
+HEADER TITLE
+
+This is
+the html text body.
+
+--=_%s
+Content-Type: text/html; charset=iso-8859-1
+Content-Description: HTML Version of Message
+
+<h1>Header Title</h1>
+<p>This is<br />the html text body.</p>
+--=_%s--",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testAddAttachment()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'body' => "This is\nthe body",
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-15'
+ ));
+ $mail->addAttachment(dirname(__FILE__) . '/fixtures/attachment.bin');
+ $mail->addAttachment(
+ dirname(__FILE__) . '/fixtures/uudecode.txt',
+ 'my_name.html',
+ 'text/html',
+ 'iso-8859-15'
+ );
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+From: sender@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: multipart/mixed; boundary="=_%s"
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+'This message is in MIME format.
+
+--=_%s
+Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
+
+This is
+the body
+
+--=_%s
+Content-Type: application/octet-stream; name=attachment.bin
+Content-Disposition: attachment; filename=attachment.bin
+Content-Transfer-Encoding: base64
+
+WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5
+bHRlciBEZWljaC4K
+--=_%s
+Content-Type: text/html; charset=iso-8859-15; name=my_name.html
+Content-Disposition: attachment; filename=my_name.html
+
+
+Ignore this text.
+
+begin 644 test.txt
++5&5S="!S=\')I;F<`
+`
+end
+
+More text to ignore.
+
+begin 755 test2.txt
+*,FYD(\'-T<FEN9P``
+`
+end
+--=_%s--',
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testReusing()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'body' => "This is\nthe body",
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-15'
+ ));
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ $mail->addHeader('To', 'recipient2@example.com');
+ $mail->send($dummy);
+
+ $hdrs1 = Horde_Mime_Headers::parseHeaders($dummy->sentMessages[0]['header_text']);
+ $hdrs2 = Horde_Mime_Headers::parseHeaders($dummy->sentMessages[1]['header_text']);
+
+ $this->assertNotEquals($hdrs1->getValue('message-id'), $hdrs2->getValue('message-id'));
+ }
+
+ public function testFlowedText()
+ {
+ $mail = new Horde_Mime_Mail();
+ $mail->addHeader('Subject', 'My Subject');
+ $mail->addHeader('To', 'recipient@example.com');
+ $mail->setBody(file_get_contents(dirname(__FILE__) . '/fixtures/flowed_msg.txt'));
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ // Need PHPUnit 3.5+
+ if (method_exists($this, 'assertStringMatchesFormat')) {
+ $this->assertStringMatchesFormat(
+'Subject: My Subject
+To: recipient@example.com
+Message-ID: <%d.%s@mail.example.com>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %d %d:%d:%d %s%d
+Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
+MIME-Version: 1.0',
+ $dummy->sentMessages[0]['header_text']
+ );
+ } else {
+ $this->markTestSkipped();
+ }
+
+ $this->assertEquals(
+'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
+minim veniam, quis nostrud exercitation ullamco laboris nisi ut
+aliquip ex ea commodo
+consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
+cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
+cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
+id est laborum.',
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+ public function testEmptyBody()
+ {
+ $mail = new Horde_Mime_Mail(array(
+ 'subject' => 'My Subject',
+ 'to' => 'recipient@example.com',
+ 'from' => 'sender@example.com',
+ 'charset' => 'iso-8859-15'
+ ));
+
+ $dummy = Horde_Mail::factory('Mock');
+ $mail->send($dummy);
+
+ $this->assertEquals(
+ "\n",
+ $dummy->sentMessages[0]['body']
+ );
+ }
+
+}
+++ /dev/null
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
-proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
--- /dev/null
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
+consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
+cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+++ /dev/null
---TEST--
-Horde_Mime_Mail constructor test
---FILE--
-<?php
-
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-require dirname(__FILE__) . '/mail_dummy.inc';
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'body' => "This is\nthe body",
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-15'));
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-
-This is
-the body
+++ /dev/null
---TEST--
-Horde_Mime_Mail methods test
---FILE--
-<?php
-
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-require dirname(__FILE__) . '/mail_dummy.inc';
-
-$mail = new Horde_Mime_Mail();
-$mail->addHeader('Subject', 'My Subject');
-$mail->setBody("This is\nthe body", 'iso-8859-15');
-$mail->addHeader('To', 'recipient@example.com');
-$mail->addHeader('Cc', 'null@example.com');
-$mail->addHeader('Bcc', 'invisible@example.com');
-$mail->addHeader('From', 'sender@example.com');
-$mail->removeHeader('Cc');
-
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-
-This is
-the body
+++ /dev/null
---TEST--
-Horde_Mime_Mail encoding test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require 'Horde/Nls.php';
-require_once 'Horde/Util.php';
-
-$mail = new Horde_Mime_Mail(array('subject' => 'Schöner Betreff',
- 'body' => "Hübsche Umlaute \n und Leerzeichen.",
- 'to' => 'Empfänger <recipient@example.com>',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-1'));
-$mail->addHeader('Cc', 'Der schöne Peter <peter@example.com>', 'iso-8859-15');
-
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: =?iso-8859-1?b?U2No9m5lcg==?= Betreff
-To: =?iso-8859-1?b?RW1wZuRuZ2Vy?= <recipient@example.com>
-From: sender@example.com
-Cc: Der =?iso-8859-15?b?c2No9m5l?= Peter <peter@example.com>
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-Content-Transfer-Encoding: quoted-printable
-
-H=FCbsche Umlaute
- und Leerzeichen.
+++ /dev/null
---TEST--
-Horde_Mime_Mail::addPart() test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'body' => "This is\nthe body",
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-15'));
-$mail->addPart('text/plain', 'This is a plain text', 'iso-8859-1', 'inline');
-$mail->addPart('application/octet-stream',
- file_get_contents(dirname(__FILE__) . '/fixtures/attachment.bin'),
- null, 'attachment');
-
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: multipart/mixed; boundary="=_%s"
-MIME-Version: 1.0
-
-This message is in MIME format.
-
---=_%s
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-
-This is
-the body
-
---=_%s
-Content-Type: text/plain; charset=iso-8859-1
-Content-Disposition: inline
-
-This is a plain text
---=_%s
-Content-Type: application/octet-stream
-Content-Disposition: attachment
-Content-Transfer-Encoding: base64
-
-WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5
-bHRlciBEZWljaC4K
---=_%s--
+++ /dev/null
---TEST--
-Horde_Mime_Mail HTML test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require_once 'Horde/Text/Filter.php';
-require_once 'Horde/Text/Filter/Base.php';
-require_once 'Horde/Text/Filter/Html2text.php';
-require_once 'Horde/Util.php';
-$mailer = new Mail_dummy();
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com'));
-$mail->setBody("This is\nthe plain text body.");
-$mail->send($mailer);
-echo $mailer->send_output;
-
-echo "====================================================================\n";
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com'));
-$mail->setHTMLBody("<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>",
- 'iso-8859-1', false);
-$mail->send($mailer);
-echo $mailer->send_output;
-
-echo "====================================================================\n";
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com'));
-$mail->setHTMLBody("<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>");
-
-$mail->send($mailer);
-echo $mailer->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-
-This is
-the plain text body.
-====================================================================
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/html; charset=iso-8859-1
-MIME-Version: 1.0
-
-<h1>Header Title</h1>
-<p>This is<br />the html text body.</p>
-====================================================================
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: multipart/alternative; boundary="=_%s"
-MIME-Version: 1.0
-
-This message is in MIME format.
-
---=_%s
-Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
-Content-Description: Plaintext Version of Message
-
-HEADER TITLE
-
-This is
-the html text body.
-
---=_%s
-Content-Type: text/html; charset=iso-8859-1
-Content-Description: HTML Version of Message
-
-<h1>Header Title</h1>
-<p>This is<br />the html text body.</p>
---=_%s--
+++ /dev/null
---TEST--
-Horde_Mime_Mail::addAttachment() test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'body' => "This is\nthe body",
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-15'));
-$mail->addAttachment(dirname(__FILE__) . '/fixtures/attachment.bin');
-$mail->addAttachment(dirname(__FILE__) . '/mail_dummy.inc', 'my_name.html', 'text/html', 'iso-8859-15');
-
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: multipart/mixed; boundary="=_%s"
-MIME-Version: 1.0
-
-This message is in MIME format.
-
---=_%s
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-
-This is
-the body
-
---=_%s
-Content-Type: application/octet-stream; name=attachment.bin
-Content-Disposition: attachment; filename=attachment.bin
-Content-Transfer-Encoding: base64
-
-WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5
-bHRlciBEZWljaC4K
---=_%s
-Content-Type: text/html; charset=iso-8859-15; name=my_name.html
-Content-Disposition: attachment; filename=my_name.html
-
-<?php
-/**
- * @package Mail
- */
-
-require_once 'Mail.php';
-require_once 'Mail/RFC822.php';
-require_once 'Horde/Browser.php';
-require_once 'Horde/Text/Flowed.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Address.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Headers.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Magic.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Mail.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Part.php';
-$_SERVER['SERVER_NAME'] = 'mail.example.com';
-
-class Mail_dummy extends Mail
-{
- public $send_output;
-
- public function send($recipients, $headers, $body)
- {
- list(,$text_headers) = Mail::prepareHeaders($headers);
- $this->send_output = $text_headers . "\n\n" . $body;
- }
-}
-
---=_%s--
+++ /dev/null
---TEST--
-Horde_Mime_Mail reusing test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-
-$dummy = new Mail_dummy();
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'body' => "This is\nthe body",
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-15'));
-
-$mail->send($dummy);
-$raw = $dummy->send_output;
-
-echo $raw;
-preg_match('/^Message-ID: (.*)$/m', $raw, $id1);
-
-echo "====================================================================\n";
-
-$mail->addHeader('To', 'Änderung <other@example.com>', 'utf-8');
-
-$mail->send($dummy);
-$raw = $dummy->send_output;
-
-echo $raw;
-preg_match('/^Message-ID: (.*)$/m', $raw, $id2);
-
-echo "====================================================================\n";
-
-var_dump($id1[1] != $id2[1]);
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-
-This is
-the body
-====================================================================
-Subject: My Subject
-From: sender@example.com
-User-Agent: Horde Application Framework 4
-Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-To: =?utf-8?b?w4RuZGVydW5n?= <other@example.com>
-Message-ID: <%d.%s@mail.example.com>
-Date: %s, %d %s %d %d:%d:%d %s%d
-
-This is
-the body
-
-====================================================================
-bool(true)
-
+++ /dev/null
---TEST--
-Horde_Mime_Mail flowed text test
---FILE--
-<?php
-
-require dirname(__FILE__) . '/mail_dummy.inc';
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-
-$mail = new Horde_Mime_Mail();
-$mail->addHeader('Subject', 'My Subject');
-$mail->addHeader('To', 'recipient@example.com');
-$mail->setBody('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.');
-
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
-MIME-Version: 1.0
-
-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
-eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
-minim veniam, quis nostrud exercitation ullamco laboris nisi ut
-aliquip ex ea commodo
-consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
-cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
-cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
-id est laborum.
+++ /dev/null
---TEST--
-Horde_Mime_Mail empty body test.
---FILE--
-<?php
-
-require_once 'Horde/String.php';
-require_once 'Horde/Util.php';
-require dirname(__FILE__) . '/mail_dummy.inc';
-
-$mail = new Horde_Mime_Mail(array('subject' => 'My Subject',
- 'to' => 'recipient@example.com',
- 'from' => 'sender@example.com',
- 'charset' => 'iso-8859-15'));
-$dummy = Mail::factory('dummy');
-$mail->send($dummy);
-echo $dummy->send_output;
-
-?>
---EXPECTF--
-Subject: My Subject
-To: recipient@example.com
-From: sender@example.com
-Message-ID: <%d.%s@mail.example.com>
-User-Agent: Horde Application Framework 4
-Date: %s, %d %s %d %d:%d:%d %s%d
-Content-Type: application/octet-stream
-MIME-Version: 1.0
+++ /dev/null
-<?php
-/**
- * @package Mail
- */
-
-require_once 'Mail.php';
-require_once 'Mail/RFC822.php';
-require_once 'Horde/Browser.php';
-require_once 'Horde/Text/Flowed.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Address.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Headers.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Magic.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Mail.php';
-require dirname(__FILE__) . '/../../../lib/Horde/Mime/Part.php';
-$_SERVER['SERVER_NAME'] = 'mail.example.com';
-
-class Mail_dummy extends Mail
-{
- public $send_output;
-
- public function send($recipients, $headers, $body)
- {
- list(,$text_headers) = Mail::prepareHeaders($headers);
- $this->send_output = $text_headers . "\n\n" . $body;
- }
-}