title: Problems with PHP Mailer header encoding
body: <pre><code>    &lt;?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-&gt;CharSet = "utf8";
  /*
  $body             = file_get_contents('contents.html');
  $body             = eregi_replace("[\]",'',$body);
  */
  $mail-&gt;IsSMTP(); // telling the class to use SMTP
  //$mail-&gt;Host       = "mail.app-cpr.com"; // SMTP server
  //$mail-&gt;SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                             // 1 = errors and messages
                                             // 2 = messages only
  $mail-&gt;SMTPAuth   = true;                  // enable SMTP authentication
  $mail-&gt;SMTPSecure = "tls";                 // sets the prefix to the servier
  $mail-&gt;Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
  $mail-&gt;Port       = 25;                   // set the SMTP port for the GMAIL server
  $mail-&gt;Username   = "xxxxxxx@gmail.com";  // GMAIL username
  $mail-&gt;Password   = "xxxxxxxxxxx";            // GMAIL password    
  $mail-&gt;SetFrom('xxxxxxx@gmail.com', 'First Last');
  
  $mail-&gt;AddReplyTo("xxxxxxx@gmail.com","First Last");
  
  $mail-&gt;Subject    = "ทดสอบ";
  /*
  $mail-&gt;AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  */
  $mail-&gt;MsgHTML("ทดสอบ");
  
  $address = "xxxxxxx@gmail.com";
  $mail-&gt;AddAddress($address, "John Doe");
  
  if(!$mail-&gt;Send()) {
    echo "Mailer Error: " . $mail-&gt;ErrorInfo;
  } else {
    echo "Message sent!";
  }
  
  ?&gt;
  </code></pre>
  
  <p>The email sending is ok but have a problems with the header.</p>
  
  <p><b>Subject : '<code>&amp;#3607;&amp;#3604;&amp;#3626;&amp;#3629;&amp;#3610;</code>'</b></p>
  
  <p>I will try with <br/>
  - <a href="https://stackoverflow.com/questions/19708097/php-mail-special-characters-utf8">php mail special characters utf8</a><br/>
  - use => $mail->Subject = "=?UTF-8?B?".base64_encode($subject)."?=";</p>
  
  <p>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?</p>