Swift Mailer 不返回 smtp 邮件失败
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请记住,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.