Reputation: 5458
I want to send out batch mails using SwiftMail or any similar system. The SwiftMailer docs state that:
"Each recipient of the messages receives a different copy with only their own email address on the To: field. An integer is returned which includes the number of successful recipients."
http://swiftmailer.org/docs/batchsend-method
I want to know whether it's possible to find out which email addresses failed, and optionally obtain the error reason/code.
Upvotes: 0
Views: 522
Reputation: 65516
There's a another page in the instructions there that talks about batchsend() failures http://swiftmailer.org/docs/finding-failures and there is an example, and I suspect batchsend will be done exactly the same way.
$mailer = Swift_Mailer::newInstance( ... );
$message = Swift_Message::newInstance( ... )
->setFrom( ... )
->setTo(array(
'[email protected]' => 'Receiver Name',
'[email protected]' => 'A name',
'[email protected]' => 'Other Name'
))
->setBody( ... )
;
//Pass a variable name to the send() method
if (!$mailer->send($message, $failures))
{
echo "Failures:";
print_r($failures);
}
/*
Failures:
Array (
0 => [email protected],
1 => [email protected]
)
*/
Upvotes: 1