Zend Mail mangles email text 
Had this strange problem ever since we upgraded a Symfony site from 1.0 to 1.2 - the emails being logged to the database were being mangled.

The problem turns out to be simply that the symfony 1.2 swToolkit plugin uses Zend Mail instead of phpMailer and Zend Mail spits out encoded text when you ask it for the email text or HTML contents.

So the simple fix is to wrap the data you get out of Zend Mail with the obscure quoted_printable_decode() function as shown here:

$message = quoted_printable_decode($zendEmail->getBodyHtml()->getContent());
$text = quoted_printable_decode($zendEmail->getBodyText()->getContent());

There, that gets rid of all those =0D=0A characters everywhere!

Note that you would think you could avoid this simply by passing the line ending explicitly, but it does not work:
//this does *NOT* work!
$message = $zendEmail->getBodyHtml()->getContent("\r\n");
$text = $zendEmail->getBodyText()->getContent("\r\n");


Comments 
Comments are not available for this entry.