ลองเอามารันใน localhost แล้ว ติด error ดังนี้ครับ
SMTP Error: Could not connect to SMTP host.
ไม่รู้ว่าต้องทำอย่างไรก่อนรึเปล่าครับ
Code (PHP)
$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 = "mypassword"; // 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
[Fri Mar 25 13:07:32 2011] [error] [client 127.0.0.1] File does not exist: C:/AppServ/www/favicon.ico
[Fri Mar 25 13:07:34 2011] [error] [client 127.0.0.1] File does not exist: C:/AppServ/www/favicon.ico
[Fri Mar 25 13:07:41 2011] [error] [client 127.0.0.1] File does not exist: C:/AppServ/www/favicon.ico
[Fri Mar 25 13:08:56 2011] [error] [client 127.0.0.1] File does not exist: C:/AppServ/www/favicon.ico
>>Use IMAP to check Gmail on other email clients[/b]
Set up IMAP and change your SMTP settings to read Gmail messages in other mail clients, like Microsoft Outlook and Apple Mail. When you use IMAP, you can read your Gmail messages on multiple devices, and messages are synced in real time. You can also read Gmail messages using POP.
Note: To avoid temporarily locking yourself out of your account, make sure you don't exceed 2500 MB per day for IMAP downloads and 500 MB per day for IMAP uploads. If you're setting up a single IMAP account on multiple computers, try taking a break between each setup.
Set up IMAP
Step 1: Check that IMAP is turned on
On your computer, open Gmail.
In the top right, click Settings Settings.
Click Settings.
Click the Forwarding and POP/IMAP tab.
In the "IMAP Access" section, select Enable IMAP.
Click Save Changes.
Step 2: Change SMTP & other settings in your email client
Use the table below to update your client with the correct information. For help updating your settings, search your email client's Help Center for instructions on setting up IMAP.
Incoming Mail (IMAP) Server
imap.gmail.com
Requires SSL: Yes
Port: 993
Outgoing Mail (SMTP) Server
smtp.gmail.com
Requires SSL: Yes
Requires TLS: Yes (if available)
Requires Authentication: Yes
Port for SSL: 465
Port for TLS/STARTTLS: 587
Full Name or Display Name Your name
Account Name, User name, or Email address Your full email address
Password Your Gmail password
พอดีผมติดปัญหาคล้ายๆ จขกท. แล้วก็แก้ตามโพสนี้ไม่ได้เหมือนกัน เลยอยากแชร์วิธีที่ผมใช้แก้ละกันครับ
ผมขอสรุปขั้นตอนการตรวจสอบและแก้ไขปัญหา SMTP Error: Could not connect to SMTP host เท่าที่ผมเคยเจอมาละกันครับ
1) ทดสอบด้วยการ Telnet เพื่อพิสูจน์ว่า เครื่องเราสามารถ Connect ไปยัง Mail Server ได้จริงๆ Address ถูกต้อง, Server Online หรือไม่ได้ถูก block จาก firewall