views:

31

answers:

1

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.

+1  A: 

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]
)
*/
Preet Sangha
I see. So I don't suppose it can return the reason for failure?
GSTAR
Sorry I don't know that.
Preet Sangha