![]() |
||
PHP SMTP Authenticationก่อนอื่นทางสาไทฯขอแจ้งให้ลูกค้าทราบว่าทางบริษัทไม่เปิดให้ใครก็ได้สามารถส่งอีเมล์โดยตรง จาก Web server ด้วย PHP mail() กรุณาใช้คำสั่ง PHP SMTP Authentication เพื่อที่จะสามารถส่งอีเมล์ได้จาก Website ของท่าน ขั้นตอนแรกคือให้ท่าน Download phpmailer.zip จาก http://www.sathaihost.com/downloads/phpmailer.zip แล้วหลักจากนั้นให้ upzip ข้อมูลไปไว้ใน folder เดียวกับ folder ที่จะสร้างไฟล์ php ส่งอีเมล์ แล้วให้ใช้ code ดังต่อไปนี้ส่งอีเมล์ครับ
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->IsHTML(true);
$mail->CharSet = "windows-874";
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPAuth = "true";
$mail->Username = "name@yourdomain.com";
$mail->Password = "password";
$mail->From = "norepl@yourdomain.com";
//The name that you'll see as Sender
$mail->FromName = "Yourdomain Webmaster";
$mail->AddAddress("friend@customerdomain.com");
$mail->Subject = "Test sending email";
$mail->Body = "<span style='color:#0000FF;'>
Dear Customer
<br /><br />
This is a sample email sent from PHP SMTP Authentication
<br /><br />
Sathai Technical Support
</span>";
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
?>
|
| |||||||||||||