【问题标题】:Port 465 seems open, but still cannot send mail端口 465 似乎打开,但仍然无法发送邮件
【发布时间】:2014-12-08 07:58:58
【问题描述】:

我已经在我的服务器上打开了 465 端口:

iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
iptables-save | sudo tee /etc/sysconfig/iptables
service iptables restart

当我运行 iptables -L -n 时,我可以看到端口是 ACCEPT

但是当我尝试发送邮件时:

$mail = new PHPMailer ();
$mail->IsSMTP ();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->Username = "gmailusername";
$mail->Password = "gmailpassword";
$mail->SetFrom ( $from, $title );
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress ( $to );
$mail->Send();

我收到以下错误:

SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
<br />The following From address failed: gmailusername : Called Mail() without being connected

任何帮助将不胜感激!

【问题讨论】:

  • 出于好奇,您的用户名gmailusername 和密码gmailpassword
  • 不,这些只是替代品。
  • 你的服务器在路由器后面吗?
  • 服务器是digitalocean,没有。
  • 你的防火墙真的做出口过滤吗?我建议在 587 上使用 TLS,而不是在 465 上使用过时的 SSL。您可以随时通过完全禁用它来检查它是否是您的防火墙。设置SMTPDebug = 4 获取连接信息。

标签: php smtp gmail phpmailer


【解决方案1】:

事实证明,digitalocean 已阻止向新用户发送电子邮件。联系了他们,现在它正在工作。希望这对某人有所帮助。

【讨论】:

    【解决方案2】:
    【解决方案3】:

    Google 的 SMTP 服务器需要身份验证,因此设置方法如下:

    1. SMTP 服务器(即外发邮件):smtp.gmail.com

    2. SMTP 用户名:您的完整 Gmail 或 Google Apps 电子邮件地址(例如 example@gmail.com 或 example@yourdomain.com)

    3. SMTP 密码:您的 Gmail 或 Google Apps 电子邮件密码

    4. SMTP 端口:465

    5. SMTP 需要 TLS/SSL:是
      为了在您的 Gmail 或已发送的 Google Apps 中存储外发电子邮件的副本 文件夹,登录您的 Gmail 或 Google Apps 电子邮件设置,然后:

    6. 单击转发/IMAP 选项卡并向下滚动到 IMAP 访问 部分:必须启用 IMAP 才能正确发送电子邮件 复制到您发送的文件夹


    发送限制

    Google 限制了用户可以通过其便携式 SMTP 服务器发送的邮件数量。 此限制将每天发送的邮件数量限制为 99 封电子邮件;并在达到限制后 24 小时内自动解除限制。


    来源: How To Use Google's SMTP Server

    【讨论】:

    • 在 587 上使用 TLS,而不是在 465 上使用 SSL,后者已弃用 15 年。
    猜你喜欢
    • 2023-03-13
    • 2013-07-21
    • 2017-08-09
    • 2021-09-15
    • 2023-01-04
    • 1970-01-01
    • 2017-02-17
    • 2020-04-14
    • 1970-01-01
    相关资源
    最近更新 更多