ZF-6173: Zend_Mail doesn't send HTML email correctly - shows up an as attachment, or plaintext (client dependent)

Issue Type: Bug Created: 2009-04-01T02:53:33.000+0000 Last Updated: 2012-11-20T21:37:52.000+0000 Status: Open Fix version(s): Reporter: Steven Bakhtiari (stevebakh) Assignee: None Tags: - Zend_Mail

Related issues: Attachments: - headers.txt


This is HTML email.


Posted by Ben Scholzen (dasprid) on 2009-04-01T03:24:13.000+0000

The attachment part is actually a Microsoft issue. Simple way to fix it is to remove the (not required) content-disposition:

<pre class="highlight">
Index: Zend/Mail.php
--- Zend/Mail.php   (revision 14574)
+++ Zend/Mail.php   (working copy)
@@ -326,7 +326,6 @@
         $mp = new Zend_Mime_Part($txt);
         $mp->encoding = $encoding;
         $mp->type = Zend_Mime::TYPE_TEXT;
-        $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
         $mp->charset = $charset;
         $this->_bodyText = $mp;
@@ -367,7 +366,6 @@
         $mp = new Zend_Mime_Part($html);
         $mp->encoding = $encoding;
         $mp->type = Zend_Mime::TYPE_HTML;
-        $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
         $mp->charset = $charset;
         $this->_bodyHtml = $mp;

Posted by Ben Scholzen (dasprid) on 2009-04-01T05:04:35.000+0000

The HTML problem in evolution seems to be related to the Exchange server, getting the mail directly from the mail account works just fine. Testing Outlook without Exchange server soon.

Posted by Ben Scholzen (dasprid) on 2009-04-01T05:49:31.000+0000

The Outlook problem also only occurs when used via Exchange server, the patch is in any case not neccessary. Doing further testing.

Posted by Steven Bakhtiari (stevebakh) on 2009-04-01T05:50:10.000+0000

Agreed - working with Ben, we've discovered the issue is not specific to the client, but more to exchange.

The tests carried out use both evolution and outlook, sitting behind an exchange server. HTML email sent from Zend_Mail exhibits the error, but when accessing POP or IMAP mail via outlook and evolution, there are no problems.

Now to find out what Zend_Mail is doing that exchange is choking on...

Posted by Steven Bakhtiari (stevebakh) on 2009-04-01T07:12:02.000+0000

The file contains headers from 4 emails.

All emails were opened in Microsoft Outlook using 2 different accounts - one IMAP, the other behind Microsoft exchange. All examples use the code presented in the initial post.

  • Sending HTML email from Zend_Mail to the account behind exchange doesn't work as intended. The html is sent as an attachment.
  • Sending HTML email from PHP's mail function to the account behind exchange works as expected.
  • Sending HTML email from Zend_mail to an IMAP account, bypassing exchange, works as intended.
  • Sending HTML email from PHP's mail function to an IMAP account, bypassing exchange, also works as intended.

So basically, in all the scenarios tried, only the scenario involving Zend_Mail and exchange doesn't work as intended. It appears the content-type and charset declarations are not present when sent from Zend_Mail to the exchange account. Without checking the code, I would assume that perhaps the content type is applied only to the content, not to the entire mail, whereas when sending using PHP's mail function, the content-type and charset are always set for the entire mail.

Posted by Steven Bakhtiari (stevebakh) on 2009-04-01T07:14:04.000+0000

Whoops, just to add to the comment above, all tests were carried out with an unpatched Zend_Mail as previous testing determined that the content-disposition issue was not at fault here.

Posted by Benjamin Eberlei (beberlei) on 2009-06-12T14:36:16.000+0000

Reset the priority from "Blocker" to "Minor" since the issue does not seem to be a Zend_Mail, but an exchange problem (i also have the same problem with exchange with other mail sending libraries).

Posted by Benjamin Eberlei (beberlei) on 2009-09-18T06:23:13.000+0000

I have tested this with Outlook 2007 behind an Exchange server and it works correctly with the Inline Content Disposition.

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2010-12-04T14:20:47.000+0000

Can we close this one?

Have you found an issue?

See the Overview section for more details.


© 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.