Swift Mailer 不返回 smtp 邮件失败

发布于 2024-12-02 18:22:54 字数 490 浏览 0 评论 0原文

我正在使用 Swiftmailer 通过 SMTP 发送电子邮件,

我需要从 SMTP 获取响应,但我尝试的方法不起作用。有可能吗?

我尝试了无效的电子邮件:[email protected] - 在下面的代码中,这确实不返回

    if (!$mailer->send($message, $fails))
    {
          echo "Failures:";
          print_r($fails);
          return false;
    }

    return true;

错误我不想使用 PhpMailer,因为我有其他问题。

I am using Swiftmailer to send emails with SMTP

I need to get response from SMTP, but what I am trying is not working. Is it even possible?

I tried an invalid email: [email protected] - on the code below, which does not return errors

    if (!$mailer->send($message, $fails))
    {
          echo "Failures:";
          print_r($fails);
          return false;
    }

    return true;

P.S. I don't want to use PhpMailer because I have other issues with it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋意浓 2024-12-09 18:22:54

请记住,Swiftmailer 只是将电子邮件交给 SMTP 服务器。它实际上并没有提供它。 Swiftmailer 的工作不是确定您告诉其发送的电子邮件地址是否有效。只要地址符合 RFC822 标准,Swiftmailer 就会接受它,并且您使用的任何 SMTP 服务器都会接受它。

只有当 SMTP 服务器尝试将电子邮件实际传送到无效主机名时,您才会遇到失败。到那时,Swiftmailer 已经断开连接并报告成功 - 它已经完成了它的使命。故障发生在更远的地方,超出了 Swiftmailer 的视野。

Remember that Swiftmailer simply hands the email over to an SMTP server. It does not actually deliver it. It's not Swiftmailer's job to determine if the email address you're telling it to send to is valid or not. As long as the address conforms to RFC822 standards, it'll be accepted by Swiftmailer, and be accepted by whatever SMTP server you're using.

It's only when that SMTP server attempts to actually DELIVER the email to the invalid hostname that you'll get a failure. By that point, Swiftmailer's already disconnected and reported success - it has accomplished its mission. The failure has occured farther down the line, outside of Swiftmailer's view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文