PHPMailer SMTP 无法连接到服务器:与 Gmail 的连接超时 (110)


PHPMailer SMTP Failed to connect to server: Connection timed out (110) to Gmail

我使用 PHPMailer 连接到端口 465 上的 Gmails MX 服务器 gmail-smtp-in.l.google.com 。这Failed to connect to server: Connection timed out (110)错误

在线阅读后,我刚刚与在端口 25 上成功运行traceroute to gmail-smtp-in.l.google.com的主机进行了聊天,我确信主机端的任何东西都没有阻止连接。

我需要在我的 Gmail 帐户中进行任何设置吗?我能够通过 SMTP 连接到其他域。


我也可以在465上连接到smtp.gmail.com,但以下命令似乎无法正常工作

RCPT TO: <wrong.email@gmail.com>

给我一个250好的。

编辑:和 im 使用 dns_get_record() 获取域的 MX 记录。

这是我写的扩展 PHPMailer 类的一部分:

$this->IsSMTP(); 
$this->Host       = $this->data['smtp_host'];
$this->Mailer   = "smtp";
$this->Timeout      = 10;
$this->SMTPDebug  = 2;
$this->SMTPAuth   = true;
$this->Port       = 465;
$this->Username   = 'my.address@gmail.com';
$this->Password   = 'my_password';
$ret[] = $this->smtpConnect();
$ret[] = $this->smtp->mail('my.address@gmail.com');
$ret[] = $this->smtp->recipient('wrong.email@gmail.com');
$this->smtpClose();

以上关于连接超时时 ssl://gmail-smtp-in.l.google.com:465 错误 (110)

ssl://smtp.gmail.com:465 说 250 好的,我应该没有得到这样的用户。

目前尚不清楚您为什么要这样做。如果您使用的是 Gmail 的 MX,则意味着您要直接 Gmail 用户发送邮件。通常,这只会在端口 25 上,但如果您想加密,只需在连接后发出 STARTTLS。465 上的 SSL 和 587 上的 TLS 是出站邮件的提交端口,所以我并不惊讶你立即得到 250 OK - 你预计稍后会出现 5.1.1 反弹。如果您在MX上尝试相同的操作,我希望它会预先失败。