PHP Mailer头编码的问题

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP Mailer头编码的问题脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?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;&#3604;&#3626;&#3629;&#3610;’

我会尝试
php mail special characters utf8
– use => $mail-> Subject =“=?UTF-8?B?”.base64_encode($subject).“?=”;

但它对我不起作用.我怎么知道标题编码是什么,并在我的泰语语言中解决这个问题?

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

代替

$mail->CharSet = "utf8";

脚本宝典总结

以上是脚本宝典为你收集整理的PHP Mailer头编码的问题全部内容,希望文章能够帮你解决PHP Mailer头编码的问题所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。