2014-07-09 15 views
7
<?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 = "[email protected]"; // GMAIL username 
$mail->Password = "xxxxxxxxxxx";   // GMAIL password  
$mail->SetFrom('[email protected]', 'First Last'); 

$mail->AddReplyTo("[email protected]","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 = "[email protected]"; 
$mail->AddAddress($address, "John Doe"); 

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

?> 

Gửi email là ok nhưng có vấn đề với tiêu đề.Sự cố với mã hóa tiêu đề Mailer PHP

Subject:. '&#3607;&#3604;&#3626;&#3629;&#3610;'

Tôi sẽ cố gắng với
- php mail special characters utf8
- base64_encode sử dụng => $ mail-> Chủ đề = "?? = UTF-8 B" ($ chủ đề). "? =";

Nhưng nó không hiệu quả với tôi. Làm thế nào tôi có thể biết được tiêu đề mã hóa và giải quyết điều này là đúng trong langauge Thái của tôi là gì?

+1

Hãy thử $ mail-> charset = "UTF-8"; –

Trả lời

17

Sử dụng

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

thay vì

$mail->CharSet = "utf8"; 

Các vấn đề liên quan