我正在使用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插件将为我提供日志,但我无法从中读取。

有帮助吗?

解决方案

您可以通过参考将变量传递到拒绝的一系列电子邮件地址 batchSend() 使系统填充:

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

那么你就可以 array_diff() 那些来自你的 $to_mail 阵列要获得成功的阵列。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top