|
 |
|
Mailer SMTP Error: Could not connect to SMTP host บนเซิฟเวอร์จริง แต่บน localhost ส่งได้ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
require_once('class.phpmailer.php');
$name = $_POST[name];
$email = $_POST[email];
$phone=$_POST[phone];
$city=$_POST[city];
$question = $_POST[message];
$mail = new PHPMailer();
$mail->CharSet="utf-8";
$mail->IsHTML(true);
$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->Username = "[email protected]"; // GMAIL username
$mail->Password = "35798642"; // GMAIL password
$mail->From = $email; // "[email protected]";
//$mail->AddReplyTo = "[email protected]"; // Reply
$mail->FromName = $name; // set from Name
$mail->Subject = "ข้อความจากผู้ติดต่อทางเว็บไซต์";
$mail->Body = "จากคุณ : ".$name." "."จังหวัด : ".$city."<br/>"."เบอร์โทรศัพท์ : ".$phone."<br/>"."E-mail : ".$email."<hr/>".$question;
$mail->AddAddress("[email protected]"); // to Address
//$mail->AddAttachment("thaicreate/myfile.zip");
//$mail->AddAttachment("thaicreate/myfile2.zip");
//$mail->AddCC("[email protected]", "Mr.Member ShotDev"); //CC
//$mail->AddBCC("[email protected]", "Mr.Member ShotDev"); //CC
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "<script>
alert('Ok')
window.location.href='contact-us.html';
</script>";
}
?>
|
 |
 |
 |
 |
Date :
2012-06-15 11:46:01 |
By :
Panupong Yomngam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จากตัวอย่างนี้
PHP Sending Email Using Gmail SMTP Account Authentication
ผมเคยเขียนไว้ครับ
Code (PHP)
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = ""; // sets the prefix to the servier
$mail->Host = "mail.thaicreate.com"; // sets GMAIL as the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "xxxxxxx"; // GMAIL password
$mail->From = "[email protected]"; // "[email protected]";
//$mail->AddReplyTo = "[email protected]"; // Reply
$mail->FromName = "Mr.Weerachai Nukitram"; // set from Name
$mail->Subject = "Test sending mail.";
$mail->Body = "My Body & <b>My Description</b>";
$mail->AddAddress("[email protected]", "Mr.Adisorn Boonsong"); // to Address
$mail->Send();
?>
|
 |
 |
 |
 |
Date :
2013-02-21 17:28:50 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|