 |
SMTP Error: Could not connect to SMTP host. ถาม PHP เรื่องการส่ง mail ด้วย Gmail Account Authentication ครับ |
|
 |
|
|
 |
 |
|
เครื่องคุณน่าจะใช้ smtp ไปไม่ได้ครับ ลอง ping smtp.gmail.com ดูน่ะครับ ว่าออกได้หรือเปล่า
|
 |
 |
 |
 |
Date :
2011-03-24 17:14:38 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ping ได้ ปกติครับ แต่ก็ขึ้น SMTP Error: Could not connect to SMTP host.
ผมใช้ appserv ครับ ต้อง set อะไรก่อนรึเปล่า
|
 |
 |
 |
 |
Date :
2011-03-25 10:21:06 |
By :
kalawa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปิดแล้วก็ยังเป็นครับ
ไม่แน่ใจ ต้องลง mail server ไรพวกนี้ไหม
แล้วใน php.ini นั้นต้อง config แก้ไขพวกนี้รึเปล่าครับ
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = [email protected]
|
 |
 |
 |
 |
Date :
2011-03-25 11:13:13 |
By :
kalawa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error log ไม่เจออะไรแปลกๆครับ
[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
จะเจอเป็นแบบนี้ส่วนใหญ่
ไปหาอ่านๆดู เห็นเค้าบอกต้องลง OpenSSL ด้วยนี่ เกี่ยวรึเปล่าครับ
ไปลองโหลดมา install ลงแล้วไม่รู้ต้องทำอะไรต่อรึไม่ พวก config
|
 |
 |
 |
 |
Date :
2011-03-25 13:03:06 |
By :
kalawa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองไปทำบนเครื่อง server ที่ใช้งานจริง เป็น IIS แล้วลอง set IIS SMTP Virtual Server
ก็ยังไม่สามารถ ส่งเมล ผ่านตัว smtp ของ gmail ได้
แต่ลอง ใช้ script ธรรมดา
https://www.thaicreate.com/php/php-send-email.html
สามารถส่งเมลได้ปกติ
เป็นไปได้หรือไม่ครับ บน server จริง ตั้งอยู่ในของมหาวิทยาลัย เค้าจะ บล็อกอะไรซักอย่างไว้
แต่ลอง Ping ก็ปกติดี 
|
 |
 |
 |
 |
Date :
2011-03-25 15:04:55 |
By :
kalawa |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นไปได้ที่จะถูก block port ครับ ลองเอาขึ้น server ดูครับ ใช้ได้ไม่มีปัญหาแน่นอนครับ
|
 |
 |
 |
 |
Date :
2011-03-25 15:10:58 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากได้แบบยังไม่ได้เอาขึ้น server จริงอ่ะคับ มีวิธีแก้ป่ะคับ หามาหลายเว็บ ทำแบบที่บอกก็ได้
|
 |
 |
 |
 |
Date :
2011-04-18 23:59:54 |
By :
art4eat |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มหาลัยน่าจะบล็อกพอร์ต 465
ทางแก้คือเอา smtp server อื่นๆมาทดลองดู อันที่เป็นพอร์ต 25 ธรรมดาๆนะ
ถ้าลองแล้วได้ก็ใช้ไปก่อน พออัปขึ้น server จริงก็เปลี่ยนมาใช้ gmail:465
หรือติดต่อฝ่ายที่ดูแลให้เปิดพอร์ต 465 ให้หน่อย
|
 |
 |
 |
 |
Date :
2011-04-19 02:17:08 |
By :
mr.v |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบให้ตรงหน่อย
|
 |
 |
 |
 |
Date :
2011-04-22 04:26:03 |
By :
กกก |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผ่านมา และ ขอยืนยันว่า การแก้ไข ;extension=php_openssl.dll เป็น extension=php_openssl.dll
และทำการการ Restart Service Appache สามารถทำให้ส่ง Mail จาก Localhost โดยผ่าน Gmail ได้ครับ 
|
 |
 |
 |
 |
Date :
2011-11-17 12:41:02 |
By :
Xkiros |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Forward port เลยครับ
|
 |
 |
 |
 |
Date :
2012-01-17 12:05:54 |
By :
zero1150kfc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
http://www.scriptdd.com/webtip/phpmailer_with_gmail.html
ลองดู Config ตัวนี้ดูครับ
|
 |
 |
 |
 |
Date :
2012-07-19 12:02:59 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่าเกิดจากการตัั้งค่าไม่ตรงกันของกล่องรับจดหมายขาเข้าและขาออก เช่น ส่งPOP ใช้กับ รับPOP ส่วนเจ้า IMAP ใช้คู่กับ SMTP เราต้องมาตั้งค่าให้ตรงกัน
>>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
https://support.google.com/mail/answer/7126229?hl=us
|
 |
 |
 |
 |
Date :
2018-06-20 14:50:14 |
By :
SSS |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอดีผมติดปัญหาคล้ายๆ จขกท. แล้วก็แก้ตามโพสนี้ไม่ได้เหมือนกัน เลยอยากแชร์วิธีที่ผมใช้แก้ละกันครับ
ผมขอสรุปขั้นตอนการตรวจสอบและแก้ไขปัญหา SMTP Error: Could not connect to SMTP host เท่าที่ผมเคยเจอมาละกันครับ
1) ทดสอบด้วยการ Telnet เพื่อพิสูจน์ว่า เครื่องเราสามารถ Connect ไปยัง Mail Server ได้จริงๆ Address ถูกต้อง, Server Online หรือไม่ได้ถูก block จาก firewall
ถ้ารอดมาได้ ก็เป็นการยืนยันแล้วว่าปัญหา มาจาก PHP Config หรือ Code ของเราแน่นอน
2) เปิด SMTP Debug เพื่อดูว่ามันตายตรงไหน จะช่วยให้เราสามารถหาสาเหตุได้ง่ายขึ้น ตามนี้
Code (PHP)
$mail->SMTPDebug = 2;
3) จาก Error ที่ได้จากข้อ 2 ส่วนใหญ่จะเกี่ยวกับ tls or ssl นี่แหละ ถ้าจะใช้ ก็ไปเปิด extension openssl ตามที่เค้าโพสด้านบน ซึ่งพอเปิดแล้ว อาจจะได้หรือไม่ได้ก็ได้ ถ้าได้ก็จบ ถ้าไม่ได้ไปดูข้อ 4 หรือ ข้ามไปข้อนี้ไปเลยก็ได้
4) ใช้วิธี ignore มันไปเลย ประมาณว่าไม่ต้อง verify อะไรแต่ขอรับรองด้วยตัวเอง ด้วยวิธีเพิ่ม smpt option เข้าไปตามนี้
Code (PHP)
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
เท่าที่ผมเจอมาก็มีตามนี้หวังว่าจะช่วยพี่น้องแก้ไขปัญหาปวกกบาลอันนี้ได้นะครับ 
|
ประวัติการแก้ไข 2019-06-17 23:30:09 2019-06-17 23:31:58 2019-06-17 23:33:00
 |
 |
 |
 |
Date :
2019-06-17 23:29:17 |
By :
Guide |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|