0

我正在使用 PHP Swift Mailer 向一组用户发送批量邮件。但我无法跟踪已发送的邮件。

我的代码:

<?php 
require_once("includes/database.class.php");
require_once("lib/swift_required.php"); 
$con=DBClass::getConnection();
$db=DBClass::getDatabase($con);

$login_id="myloginname";
$password="mypassword";

$to_mail; //list of people 

//Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") 
          ->setUsername($login_id)
          ->setPassword($password);

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);


 //Rate limit to 25 emails per-minute
$mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
25, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
        ));

//Create a message
        $message = Swift_Message::newInstance($subject)
          ->setFrom($login_id)
          ->setTo($to_mail)
          ->setBody($body,
                    'text/html'
                    ); 

$numSent=$mailer->batchSend($message);
?>

我正在使用 batchSend() 方法发送邮件,它给了我已发送邮件的计数,但它没有给我已发送的电子邮件列表。怎么可能,有没有可用的插件或功能?

使用 Logger 插件会给我日志,但我无法从中读取。

4

1 回答 1

2

您可以通过引用传递变量来获取被拒绝的电子邮件地址数组以batchSend()供系统填写:

http://swiftmailer.org/docs/failures-byreference

然后你可以array_diff()从你的$to_mail阵列中获得成功的那些。

于 2010-09-18T06:43:38.923 回答