Fix sending mails with empty bodies.
authorJan Schneider <jan@horde.org>
Fri, 7 May 2010 12:28:29 +0000 (14:28 +0200)
committerJan Schneider <jan@horde.org>
Fri, 7 May 2010 12:28:56 +0000 (14:28 +0200)
framework/Mime/lib/Horde/Mime/Mail.php
framework/Mime/test/Horde/Mime/mail_009.phpt [new file with mode: 0644]

index d58d4f1..3504d88 100644 (file)
@@ -442,9 +442,8 @@ class Horde_Mime_Mail
             }
 
             /* Build mime message. */
-            $body = null;
+            $body = new Horde_Mime_Part();
             if (!empty($this->_body) && !empty($this->_htmlBody)) {
-                $body = new Horde_Mime_Part();
                 $body->setType('multipart/alternative');
                 $this->_body->setDescription(_("Plaintext Version of Message"));
                 $body->addPart($this->_body);
diff --git a/framework/Mime/test/Horde/Mime/mail_009.phpt b/framework/Mime/test/Horde/Mime/mail_009.phpt
new file mode 100644 (file)
index 0000000..718b1b1
--- /dev/null
@@ -0,0 +1,27 @@
+--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