PHP邮件头编码问题 [英] Problems with PHP Mailer header encoding

查看:114
本文介绍了PHP邮件头编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <?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!";
}

?>

电子邮件发送确定,但头标有问题。

The email sending is ok but have a problems with the header.

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

我会尝试与
- php邮件特殊字符utf8 _
- use => $ mail-> Subject ==?UTF-8?B? base64_encode($ subject)。?=;

I will try with
- php mail special characters utf8
- use => $mail->Subject = "=?UTF-8?B?".base64_encode($subject)."?=";

但它对我来说不起作用。我如何知道什么是标题编码,并解决这个问题在我的泰国语言中是正确的?

But it does not work for me. How can I know what is the header coding and solve this to be right in my Thai langauge?

推荐答案

使用

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

而不是

$mail->CharSet = "utf8";

这篇关于PHP邮件头编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆