Swiftmailer 4 不会将退回邮件检索为 $failedRecipients
我正在尝试这段代码(来自 http://swiftmailer.org/docs/sending.html) :
require_once 'lib/swift_required.php';
//Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
//Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('[email protected]' => 'John Doe'))
->setBody('Here is the message itself')
;
//Send the message
$failedRecipients = array();
$numSent = 0;
$to = array('[email protected]', '[email protected]' => 'A name');
foreach ($to as $address => $name)
{
$message->setTo(array($address => $name));
$numSent += $this->send($message, $failedRecipients);
}
printf("Sent %d messages\n", $numSent);
问题是,如果我向坏域 swiftmailer 发送电子邮件,Swiftmailer 会将其识别为正确发送的电子邮件,并且 $failedRecipients
为空。在我的邮箱中,我已返回失败通知。
为什么 Swiftmailer 不将此邮件识别为失败,并且不填充 $failedRecipients
Array
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Swiftmailer 只负责将电子邮件交给邮件服务器。其他一切都与 Swiftmailer 无关。
您收到的是退回邮件,您需要自己处理它们,因为电子邮件本身实际上是一个语法上的邮件地址,没有被第一个服务器拒绝。
顺便说一句,任何其他邮件库甚至 php
mail
函数都是如此。您可能正在寻找退回邮件处理应用程序或代码。相关:使用 PHP 处理退回电子邮件?
Swiftmailer only takes care to hand the email over to the mail-server. Everything else is not related to Swiftmailer.
What you get is a bounce message, and you need to process them on your own, because the email itself actually was a syntactically mail address that was not rejected by the first server.
That btw is the case for any other mailing library and even the php
mail
function. You might be looking for a bounce processing application or code.Related: Bounce Email handling with PHP?