0

SwiftMailなどのシステムを使ってバッチメールを送信したい。SwiftMailerのドキュメントには次のように記載されています。

「メッセージの各受信者は、To:フィールドに自分の電子メールアドレスのみが記載された異なるコピーを受信します。成功した受信者の数を含む整数が返されます。」

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 に答える