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