Issues

ZF-328: Zend_Mail / Zend_Mime does not allow use of 'Content-type: multipart/related'

Issue Type: Bug Created: 2006-08-19T17:45:56.000+0000 Last Updated: 2009-10-31T05:51:45.000+0000 Status: Resolved Fix version(s): - 0.9.2 (06/Apr/07)

Reporter: Adam Wagner (awagner83) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Mail

  • Zend_Mime

Related issues: Attachments:

Description

For messages with attachments, the Content-type header is always set to multipart/mixed.

A constant Zend_Mime::MULTIPART_RELATED exists, but never seems to be used, and manually changed content-type headers get overwritten in Zend_Mail_Transport_Abstract::_getHeaders()

See for more info: library/Zend/Mime.php:45 library/Zend/Mail/Abstract.php:133,137

Comments

Posted by Bill Karwin (bkarwin) on 2006-11-28T17:51:46.000+0000

Scheduling for 0.7.0 release.

Posted by Roman Roan (videinfra) on 2006-12-12T05:49:31.000+0000

Patch:

<pre class="highlight">

Index: /Zend/Mail/Transport/Abstract.php
===================================================================
--- /Zend/Mail/Transport/Abstract.php (revision 273)
+++ /Zend/Mail/Transport/Abstract.php (revision 274)
@@ -130,10 +130,13 @@
         if (null !== $boundary) {
             // Build multipart mail
-            if ($this->_mail->hasAttachments) {
-                $type = Zend_Mime::MULTIPART_MIXED;
-            } elseif ($this->_mail->getBodyText() && $this->_mail->getBodyHtml()) {
-                $type = Zend_Mime::MULTIPART_ALTERNATIVE;
-            } else {
-                $type = Zend_Mime::MULTIPART_MIXED;
+            $type = $this->_mail->getType();
+            if (!$type) {
+               if ($this->_mail->hasAttachments) {
+                   $type = Zend_Mime::MULTIPART_MIXED;
+               } elseif ($this->_mail->getBodyText() && $this->_mail->getBodyHtml()) {
+                   $type = Zend_Mime::MULTIPART_ALTERNATIVE;
+               } else {
+                   $type = Zend_Mime::MULTIPART_MIXED;
+               }
             }
 
Index: /Zend/Mail.php
===================================================================
--- /Zend/Mail.php (revision 273)
+++ /Zend/Mail.php (revision 274)
@@ -77,4 +77,10 @@
     protected $_charset = null;
 
+    /**
+     * Mail content type
+     * @var string
+     */
+    protected $_type = null;
+
     /**
      * Mail headers
@@ -172,4 +178,25 @@
     {
         return $this->_charset;
+    }
+
+    /**
+     * Sets Content-type of the message
+     *
+     * @param string $email
+     */
+    public function setType($type)
+    {
+        $this->_type = $type;
+    }
+
+    /**
+     * Return content type
+     * 
+     * @access public
+     * @return string
+     */
+    public function getType()
+    {
+        return $this->_type;
     }
 

Posted by Matthew Weier O'Phinney (matthew) on 2007-04-03T12:40:47.000+0000

Resolved in r4329. setType() only allows setting multipart content-types, and only accessed when a boundary is detected in the transport.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts