php – 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('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为空.在我的邮箱中,我收到了失败通知.

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

解决方法:

Swiftmailer只关注将电子邮件传递给邮件服务器.其他一切与Swiftmailer无关.

你得到的是退回邮件,你需要自己处理它们,因为电子邮件本身实际上是一个语法邮件地址,没有被第一台服务器拒绝.

btw是任何其他邮件库甚至PHP邮件功能的情况.您可能正在寻找退回处理应用程序或代码.

相关:Bounce Email handling with PHP?

上一篇:修改PHP电子邮件中的日期标题?


下一篇:使用PHP从localhost发送邮件