Swiftmailer 4 does not retrieve bounces as $failedRecipients

社会主义新天地 提交于 2019-11-30 09:36:00

问题


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);

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?


回答1:


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?



来源:https://stackoverflow.com/questions/6995785/swiftmailer-4-does-not-retrieve-bounces-as-failedrecipients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!