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

?> 

L'invio di e-mail è ok ma ha un problema con l'intestazione.Problemi con la codifica dell'intestazione PHP Mailer

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

cercherò con
- php mail special characters utf8
- usare => $ mail-> Subject = "??? = UTF-8 B" base64_encode ($ subject). "=?";

Ma non funziona per me. Come posso sapere qual è la codifica dell'intestazione e risolvere questo problema nel mio langauge tailandese?

+1

Prova $ mail-> charset = "UTF-8"; –

risposta

17

Usa

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

invece di

$mail->CharSet = "utf8";