<?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!"; } ?>
主题:’ทดสอบ’
我会尝试
– php mail special characters utf8
– use => $mail-> Subject =“=?UTF-8?B?”.base64_encode($subject).“?=”;
使用
$mail->CharSet = 'UTF-8';
代替
$mail->CharSet = "utf8";
原文地址:https://www.jb51.cc/php/134965.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。