我使用 smtp gmail 创建了一个电子邮件程序。我的代码适用于开发,但当我将其部署到生产环境时却不起作用。
$config['smtp_host'] = "ssl://smtp.gmail.com";
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1689
The following SMTP error was encountered: 110 Connection timed out
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:
from:
The following SMTP error was encountered:
Unable to send data: RCPT TO:
to:
The following SMTP error was encountered:
Unable to send data: DATA
data:
我之前在开发中遇到过这个问题,修复只是添加这一行。
$this->email->set_newline("\r\n");
但它不适用于生产环境。
最佳答案
Connection timed out
意味着,它甚至无法连接到服务器。
如果这在开发中有效,但在生产中无效,您可能在生产系统前面有一个防火墙来保护它,这会阻止访问。
关于php - 当我在生产环境中部署代码时,SMTP 无法在 Code Igniter 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23833818/