How to preview Zend_Mail's HTML code?

I'm creating a newsletter with dynamic content via Zend_Mail, however i want to validate the generated HTML code against W3C, is there a way to get the entire email code to be sent so I can grab it an validate? the getBodyHtml function is not returning the code properly, as it adds stuff like: <tr>=0D=0A=<td width=3D"100%">=0D=0A to the email.

Answers


It is returning the HTML like that because it is encoding it using quoted-printable encoding which is how the content is actually sent in the mail message.

If you would like to get the content without the encoding, you can try this:

$part = $mail->getBodyHtml();   // returns Zend_Mime_Part
if ($part !== false && $part instanceof Zend_Mime_Part) {
    $html = $part->getRawContent(); // returns the raw, unencoded content
}

When you set the body HTML with Zend_Mail::setBodyHtml(), you can specify the encoding. Function prototype is setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)

Valid options are

  • Zend_Mime::ENCODING_7BIT
  • Zend_Mime::ENCODING_8BIT
  • Zend_Mime::ENCODING_QUOTEDPRINTABLE (default)
  • Zend_Mime::ENCODING_BASE64

You can either validate the HTML before you call setBodyHtml if possible, or retrieve the raw, unencoded content using the method shown above. Otherwise getBodyHtml() will return the HTML in its encoded format.


Need Your Help

Client to server connection only sending not receiving

client-server send socks

This is my case, I have a server listening for connections, and a client that I'm programming now. The client has nothing to receive from the server, yet it has to be sending status updates every 3

Does Prototype's Array.compact() filter recursively for multidimensional arrays?

prototype arrays object multidimensional-array

I'm just wondering if Prototype's helper functions Array.compact() and Array.without() filter for multidimensional arrays. It doesn't look like it, and if so, was there a reason for this or is there

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.