Swiftmailer 4 不会将退回邮件检索为 $failedRecipients

发布于 2024-11-28 19:02:24 字数 1474 浏览 1 评论 0 原文

我正在尝试这段代码(来自 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

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('[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);

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.

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

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

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

发布评论

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

评论(1

黯然 2024-12-05 19:02:24

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?

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