How to view Zend_Mail HTML code?

I am creating a dynamic content newsletter through Zend_Mail, however I want to check the received HTML code on W3C, is there a way to get all the email code to send so I can check it? the getBodyHtml function does not return the code properly, because it adds things to the email, such as: <tr>=0D=0A=<td width=3D"100%">=0D=0A .

+4
source share
1 answer

It returns HTML like this because it encodes it using quotation mark encoding, which is how the content is actually sent in the mail.

If you want to receive content without encoding, you can try the following:

 $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 using Zend_Mail :: setBodyHtml (), you can specify the encoding. Function prototype setBodyHtml($html, $charset = null, $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE)

Valid parameters:

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

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

+6
source

Source: https://habr.com/ru/post/1383701/


All Articles