PHPMailer 无法连接 ot 服务器

标签 php email tcp phpmailer

PHPmailer 在我的本地主机上工作得很好,但是当我将它移动到生产环境时,我遇到了这种错误:

Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( ) 2016-09-28 12:58:01 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to smtp.gmail.com:587 (Connection timed out) 2016-09-28 12:58:01 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2016-09-28 12:58:01 SMTP connect() failed.

我已经尝试了 TLS 和 SSL,相应地更新了端口。 我还运行了一个快速的 nmap 扫描,它显示端口已正确打开,所以这不是问题

PORT    STATE    SERVICE
25/tcp  filtered smtp
443/tcp open     https
465/tcp open     smtps
587/tcp open     submission

这是我的应用程序的一个片段:

public function __construct() {
    parent::__construct();

    $this->isSMTP();
    $this->SMTPAuth = true;
    $this->SMTPSecure = 'tls';
    $this->Host = MAIL_HOST;
    $this->Username = MAIL_USERNAME;
    $this->Password = MAIL_PASSWORD;
    $this->From = 'myemail';
    $this->FromName = 'Name';
    $this->addEmbeddedImage('../public/img/message_logo.png', 'logo');
    $this->isHTML(true);
    $this->Port = 587;
    $this->Subject = "SUBJECT";
    $this->SMTPDebug = MAIL_SMTP_DEBUG;
}

有人知道接下来要检查什么吗?

最佳答案

这是一个非常常见的问题,通常是由您的 ISP 阻止出站 SMTP 引起的,例如GoDaddy 就是这样做的。什么是 nmap 扫描?电子邮件?

根据错误消息的内容,我也猜测您使用的是旧版本的 PHPMailer。

诊断此类问题包含在 the PHPMailer troubleshooting guide 中.

关于PHPMailer 无法连接 ot 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39748455/

相关文章:

php - SQL JOIN 问题不从查询中返回用户详细信息并将它们打印在数组中

email - 如何在java邮件中设置smtp认证邮件以外的邮件地址

c - 即使在关闭套接字后,服务器仍继续在客户端/服务器 C 应用程序中运行

php - 如何通过id查询数据库中的所有条目?

mysql - 阻止用户访问管理区域

php - WP自定义注销

networking - 在 CRC 错误的情况下切换表

php - 同一页面上的联系表单错误消息

php - 电子邮件附件无法正确发送

tcp - BPF 过滤器 TCP 连接