ขอเล่าที่มาก่อนนะครับ
เวปไซต์ของผม หน้าเพจผู้ใช้จะมีการกรอกข้อมูล เมื่อผู้ใช้คลิกส่งข้อมูล ระบบก็จะทำการส่งข้อมูลไปหาผู้กรอก ทาง
Email ทันที
ก่อนหน้านี้ระบบ Mail ใช้งานได้ปกติ แต่พอมาระยะหลังสัก 1 อาทิตย์กว่าๆ เริ่มมีอาการคือ
มีอาการส่ง Mail ไม่ออก จะส่ง Mail ออกได้เป็นบางเวลา ช่วงกลางวันส่งแทบไม่ได้เลย จะใช้ได้ส่วนมากก็จะเป็นช่วงกลางคืน
ดึกๆ
หากระบบ Mail ส่งไม่ได้จะแจ้ง Messages ว่า
SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
SMTP Error: Could not connect to SMTP host.
ระบบการส่ง Email ผมใช้ PHPMailer โดยใช้ smtp.gmail.com
Code ที่ผมใช้อยู่ครับ
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->CharSet = "utf-8";
$mail->Host = "mail.".$w_webdomain_f; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = $w_email_f; // GMAIL username
$mail->Password = "xxxxxxxxxxxxxx"; // GMAIL password
//------------------------------------------------------------------------------
$mail->SetFrom($w_email_f, $head_subject_f); //Email ชื่อ นามสกุล ผู้ส่ง
$mail->AddReplyTo($email_reply, $nameReply_RX_f); //Email ชื่อ นามสกุล ผู้รับ ของการตอบกลับ
$mail->Subject = $subject_f; //หัวข้อจดหมาย
$mail->MsgHTML($mail_body);
//==Email ปลายทาง=======
$address = $email_RX; //Email ผู้รับ
$mail->AddAddress($address, $fname_RX.' '.$lname_RX); //ชื่อนามสกุลผู้รับ
if(!$mail->Send())
{
echo "<font size='6' color='blue'>พบปัญหา!!..ไม่สามารถส่ง Email ได้..</font><BR>".$mail->ErrorInfo;
Exit;
}
ขอให้เพื่อนๆช่วยชี้แนะด้วยครับ ผมก็ขลุกกับปัญหานี้มาหลายวันแล้ว ยังแกะไม่ออกเลย

ขอบคุณครับ
PHPMailer ส่งเมล์ผ่าน gmail smtp กลางคืนใช้งานได้ปกติ แต่พอกลางวันส่ง Mail ไม่ออก หาปมปัญหาไม่เจอครับ
เวปไซต์ของผม หน้าเพจผู้ใช้จะมีการกรอกข้อมูล เมื่อผู้ใช้คลิกส่งข้อมูล ระบบก็จะทำการส่งข้อมูลไปหาผู้กรอก ทาง
Email ทันที
ก่อนหน้านี้ระบบ Mail ใช้งานได้ปกติ แต่พอมาระยะหลังสัก 1 อาทิตย์กว่าๆ เริ่มมีอาการคือ
มีอาการส่ง Mail ไม่ออก จะส่ง Mail ออกได้เป็นบางเวลา ช่วงกลางวันส่งแทบไม่ได้เลย จะใช้ได้ส่วนมากก็จะเป็นช่วงกลางคืน
ดึกๆ
หากระบบ Mail ส่งไม่ได้จะแจ้ง Messages ว่า
SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
SMTP Error: Could not connect to SMTP host.
ระบบการส่ง Email ผมใช้ PHPMailer โดยใช้ smtp.gmail.com
Code ที่ผมใช้อยู่ครับ
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->CharSet = "utf-8";
$mail->Host = "mail.".$w_webdomain_f; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the server
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = $w_email_f; // GMAIL username
$mail->Password = "xxxxxxxxxxxxxx"; // GMAIL password
//------------------------------------------------------------------------------
$mail->SetFrom($w_email_f, $head_subject_f); //Email ชื่อ นามสกุล ผู้ส่ง
$mail->AddReplyTo($email_reply, $nameReply_RX_f); //Email ชื่อ นามสกุล ผู้รับ ของการตอบกลับ
$mail->Subject = $subject_f; //หัวข้อจดหมาย
$mail->MsgHTML($mail_body);
//==Email ปลายทาง=======
$address = $email_RX; //Email ผู้รับ
$mail->AddAddress($address, $fname_RX.' '.$lname_RX); //ชื่อนามสกุลผู้รับ
if(!$mail->Send())
{
echo "<font size='6' color='blue'>พบปัญหา!!..ไม่สามารถส่ง Email ได้..</font><BR>".$mail->ErrorInfo;
Exit;
}
ขอให้เพื่อนๆช่วยชี้แนะด้วยครับ ผมก็ขลุกกับปัญหานี้มาหลายวันแล้ว ยังแกะไม่ออกเลย