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

Error while storing VarLongWritable format into HBase

hbase mahout sequencefile

My Map Reduce program is reading values from sequence file where format of input key and value is VarLongWritable and VectorWritable respectively. I have to insert these values into HBase pre-exist...

Problems with hooks and keys

c++ windows winapi keyboard keylogger

here is what I've done so far trying to learn to deal with hooks, buttons and messages on windows: