0

How do I fix the character encoding for this:

require_once(/Mail/mime.php");

$corpoTxt = 'Teste envio relatórios são';
$corpoHtml= '<html><body>Versão HTML do texto</body></html>';

I tried:

$corpoTxt=$mime->encodeHeader("corpo", $corpoTxt, "utf-8", "quoted-printable");
$corpoHtml=$mime->encodeHeader("corpohtmls", $corpoHtml, "utf-8", "quoted-printable");

But it doesn't work, I get:

Versão HTML do texto

Thanks in advance for any help!

1 Answers1

0

Try including these lines prior to calling the $mine-headers() function.

# Ensure EML is UTF-8 compliant
$mimeparams["debug"] = "True";
$mimeparams['text_encoding'] = "8bit";
$mimeparams['text_charset'] = "UTF-8";
$mimeparams['html_charset'] = "UTF-8";
$mimeparams['head_charset'] = "UTF-8";
$mime->get($mimeparams);

This will ensure your UTF-8 characters will display properly in the EML. Finally, save the TXT and HTML body like so:

    $mime->setTXTBody($corpoTxt);
    $mime->setHTMLBody($corpoHtml);

That should work. For more help, have a look at:

Pear Mail, how to send plain/text + text/html in UTF-8

Community
  • 1
  • 1
dearsina
  • 4,774
  • 2
  • 28
  • 34