PHP Pear Mail_Mime:如何修复字符编码?

时间:2014-04-21 14:33:18

标签: php email pear

我尝试使用PHP Pear Mail_mime发送带有附件的电子邮件,如下所示:

require_once("/../Mail/mime.php"); 

            $mimeparams['text_encoding']="8bit"; 
            $mimeparams['text_charset']="UTF-8"; 
            $mimeparams['html_charset']="UTF-8"; 
            $mimeparams['head_charset']="UTF-8"; 


            $text = 'Segue em anexo o seu relatório mensal';
            $html = '<html><body>Teste envio relatórios são</body></html>';

        $file = "/../files/abc.pdf";
        $crlf = "\n";
        $hdrs = array(
                      'From'    => '<test@example.com>',
                      'Subject' => 'Relatório'
                      );

        $mime = new Mail_mime(array('eol' => $crlf));

        $mime->setTXTBody($text);
        $mime->setHTMLBody($html);
        $mime->addAttachment($file, 'text/plain');

        $body = $mime->get();
        $hdrs = $mime->headers($hdrs);

        $mail =& Mail::factory('mail');
        $mail->send('test2@gmail.com', $hdrs, $body);

除字符编码外,它工作正常。关于邮件主题,我得到:

Relatório

而不是

Relatório

在身体里,我得到了:

Teste envio relatórios são

而不是:

Teste envio relatórios são

我试过包括:

$mimeparams['text_encoding']="8bit"; 
$mimeparams['text_charset']="UTF-8"; 
$mimeparams['html_charset']="UTF-8"; 
$mimeparams['head_charset']="UTF-8"; 

here所示,但它没有效果。

0 个答案:

没有答案