เอา ; ออกตรง open_ssl ใน php.ini แล้วนะครับ
โค้ด: เลือกทั้งหมด
<?
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true); // กำหนดให้ ส่งเป็น html
$mail->IsSMTP();
$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->Host = 'ssl://smtp.gmail.com:465'; // รวมเป็น ตัวแปลเดียวแบบนี้ก็ได้
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "xxxxx"; // ใส่พาส
$mail->From = "[email protected]"; // "[email protected]";
$mail->FromName = "ชื่อผู้ส่ง";
$mail->Subject = "หัวข้ออีกเมล";
$mail->Body = "ข้อความที่จะส่ง เป็น html ก็ได้";
$mail->AddAddress("xxxx", "ชื่อผู้รับ"); // ใส่ email ผู้รับอย่างเดียวก็ได้
$mail->Send(); // ส่งเมลออก
?>