通过 SMTP 和 PHPMailer 发送外发邮件时出现超时错误

Timeout error when sending outgoing mail via SMTP & PHPMailer

我正在尝试配置 Digital Ocean Droplet 以使用我的 Gmail 帐户的 SMTP 服务器发送外发邮件,但我收到以下错误:

2015/12/15 22:15:33 [error] 14940#0: *31 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 173.245.54.200, server: kokorugs.com, request: "POST /wp-admin/options-general.php?page=swpsmtp_settings&w3tc_note=flush_pgcache HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "kokorugs.com", referrer: "https://kokorugs.com/wp-admin/options-general.php?page=swpsmtp_settings&w3tc_note=flush_pgcache"

我是 运行 HHVM 和 nginx 上的 WordPress。

电子邮件正在由 PHPMailer 发送,这是导致超时的特定行:

if ( ! $mail->Send() )

我已经将我的 Droplet 配置为降低 IPv6 NS 查找的优先级,如 here 所述。

如果重要的话,我也在使用 CloudFlare。

什么可能导致此超时?

更新: 电子邮件发送得很好。但是服务器还是超时了。

问题是我的 Digital Ocean droplet 上没有安装 MTA

我遵循了这些说明:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04

并将 postfix 设置为仅发送 smtp 服务器。

接下来,我设置了一个 Google Apps SMTP Relay 以允许电子邮件来自我的 Google Apps 地址。

这样,发送的电子邮件将保存在我的 gmail 的已发送文件夹中,并且电子邮件被标记为垃圾邮件的可能性大大降低。