ผมใช้โค้ดนี้ครับ<br>
<?
require_once( 'class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->Encoding = "quoted-printable";
$mail->CharSet = "utf-8";
// send mail by gmail
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "********"; // GMAIL password
print "ทดสอบ1";
//$mail->AddReplyTo = "[email protected]"; // Reply
$mail->FromName = "[email protected]"; // set from Name
$mail->Subject = "Test sending mail."; print "ทดสอบ2";
$mail->Body = "My Body & <b>My Description</b>"; print "3";
$mail->AddAddress("[email protected]", "Mr.Adisorn Boonsong"); print "ทดสอบ4";
$mail->Send();
$mail -> ClearAddresses();
print "ทดสอบ5";
return true;
}
catch (phpmailerException$e) {
return false; //Pretty error messages from PHPMailer
print "ทดสอบ6";
}
catch (Exception $e) {
return false; //Boring error messages from anything else!
print "ทดสอบ7";
}
?>