ลองอะนนี้ดูนะครับ
เขียน Script php send mail ส่งเมล์ hotmail ไม่ใช้เข้า Junk Mail ด้วย SMTP ของ Gmail
โดยใช้ phpMailer
ก่อนเขียน ต้องเตรียมตัวกันก่อน
1. ดาวน์โหลด phpMailer เวอร์ชั่นล่าสุดที่นี่
2. เปิดใช้งาน openssl ใน php.ini โดย เอาเครื่องหมาย ; หน้า extension=php_openssl.dll ออก Save แล้ว restart webserver
3. แตกไฟล์ phpMailer_vx.x ไปไว้ใน Folder ที่เราต้องการ
โค้ด php ที่ใช้ในการส่งเมล
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 = "
xxx@gmail.com"; // GMAIL username
$mail->Password = "xxxxx"; // GMAIL password
$mail->From = "เมลผู้ส่ง"; // "
name@yourdomain.com";
$mail->FromName = "ชื่อผู้ส่ง";
$mail->Subject = "หัวข้ออีกเมล";
$mail->Body = "ข้อความที่จะส่ง เป็น html ก็ได้";
$mail->AddAddress("e-mail ผู้รับ", "ชื่อผู้รับ"); // ใส่ email ผู้รับอย่างเดียวก็ได้
$mail->Send(); // ส่งเมลออก
credit
http://www.mindphp.com/modules...s&file=article&sid=101