0

我想使用 SwiftMail 或任何类似系统发送批量邮件。SwiftMailer 文档指出:

“邮件的每个收件人都会收到一份不同的副本,在收件人:字段中只有他们自己的电子邮件地址。返回一个整数,其中包括成功收件人的数量。”

http://swiftmailer.org/docs/batchsend-method

我想知道是否有可能找出哪些电子邮件地址失败,并可选择获取错误原因/代码。

4

1 回答 1

1

那里的说明中有另一个页面讨论了 batchsend() 失败http://swiftmailer.org/docs/finding-failures并且有一个示例我怀疑 batchsend 将以完全相同的方式完成

$mailer = Swift_Mailer::newInstance( ... );

$message = Swift_Message::newInstance( ... )
  ->setFrom( ... )
  ->setTo(array(
    'receiver@bad-domain.org' => 'Receiver Name',
    'other@domain.org' => 'A name',
    'other-receiver@bad-domain.org' => 'Other Name'
  ))
  ->setBody( ... )
  ;

//Pass a variable name to the send() method
if (!$mailer->send($message, $failures))
{
  echo "Failures:";
  print_r($failures);
}

/*
Failures:
Array (
  0 => receiver@bad-domain.org,
  1 => other-receiver@bad-domain.org
)
*/
于 2010-07-18T20:58:15.903 回答