Swiftmailer 4 不会将退回邮件检索为 $failedRecipients [英] Swiftmailer 4 does not retrieve bounces as $failedRecipients

查看:39
本文介绍了Swiftmailer 4 不会将退回邮件检索为 $failedRecipients的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试此代码(来自 http://swiftmailer.org/docs/sending.html):

I am trying this code (from 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('john@doe.com' => 'John Doe'))
  ->setBody('Here is the message itself')
  ;

//Send the message
$failedRecipients = array();
$numSent = 0;
$to = array('receiver@domain.org', 'other@baddomain.org' => 'A name');

foreach ($to as $address => $name)
{
  $message->setTo(array($address => $name));
  $numSent += $this->send($message, $failedRecipients);
}

printf("Sent %d messages\n", $numSent);

问题是,如果我向坏域发送电子邮件,swiftmailer 会将其识别为正确发送的电子邮件,并且 $failedRecipients 为空.在我的邮箱中,我已返回失败通知.

The problem is that if I sent an email to a bad domain swiftmailer recognize it as a correct sent email and $failedRecipients is empty. In my mail box I have returned a failure notice.

为什么 Swiftmailer 不将此邮件识别为失败,并且不填充 $failedRecipients Array?

Why does Swiftmailer not recognize this mail as as a failure, and does not populate $failedRecipients Array?

推荐答案

Swiftmailer 只负责将电子邮件交给邮件服务器.其他一切都与 Swiftmailer 无关.

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.

顺便说一句,任何其他邮件库,甚至 php mail 函数都是如此.您可能正在寻找退回处理应用程序或代码.

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.

相关:使用 PHP 处理退回邮件?

这篇关于Swiftmailer 4 不会将退回邮件检索为 $failedRecipients的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆