【问题标题】:Problems with PHP Mailer header encodingPHP Mailer 标头编码的问题
【发布时间】:2014-08-30 10:17:11
【问题描述】:
    <?php
require_once('../class.phpmailer.php');
//include("../class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
iconv_set_encoding("internal_encoding", "UTF-8");

$mail             = new PHPMailer();
$mail->CharSet = "utf8";
/*
$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);
*/
$mail->IsSMTP(); // telling the class to use SMTP
//$mail->Host       = "mail.app-cpr.com"; // SMTP server
//$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 25;                   // set the SMTP port for the GMAIL server
$mail->Username   = "xxxxxxx@gmail.com";  // GMAIL username
$mail->Password   = "xxxxxxxxxxx";            // GMAIL password    
$mail->SetFrom('xxxxxxx@gmail.com', 'First Last');

$mail->AddReplyTo("xxxxxxx@gmail.com","First Last");

$mail->Subject    = "ทดสอบ";
/*
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
*/
$mail->MsgHTML("ทดสอบ");

$address = "xxxxxxx@gmail.com";
$mail->AddAddress($address, "John Doe");

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

电子邮件发送正常,但标题有问题。

主题:'&amp;#3607;&amp;#3604;&amp;#3626;&amp;#3629;&amp;#3610;'

我会尝试
- php mail special characters utf8
- 使用 => $mail->Subject = "=?UTF-8?B?".base64_encode($subject)."?=";

但这对我不起作用。我怎样才能知道什么是标题编码并在我的泰语中解决这个问题?

【问题讨论】:

  • 试试 $mail->CharSet = "UTF-8";

标签: php email encoding character-encoding phpmailer


【解决方案1】:

使用

$mail->CharSet = 'UTF-8';

而不是

$mail->CharSet = "utf8";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 2013-05-02
    • 2012-03-12
    • 2011-08-31
    • 1970-01-01
    相关资源
    最近更新 更多