我这里有一个大问题! 我需要向所有订阅者(大约 1200 个)发送新闻通讯 问题是它只向其中 150-180 人发送时事通讯。 我有一个用 php 实现的脚本,它使用 PhpMailer() 类将新闻通讯发送给所有订阅者。
我在 MailJet 中购买了一个计划,该计划允许我每月发送 3 万封电子邮件,因此我使用他们的 SMTP 主机来发送新闻通讯。
这是我的脚本:
$mail = new PHPMailer();
$body = $message;
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "in.mailjet.com";
$mail->Port = 80;
$mail->Username = "username";
$mail->Password = "password";
// thing regarding the body, subject, etc of the email //
$to_list = explode(',',$to);
$between_delay = 75; //max limit of mails send at a slot
$send_count = 1;
$send_delay = 1; //Delays the program execution for the given number of seconds.
ignore_user_abort(true); // Ignore user aborts and allow the script to run forever
set_time_limit(300); //to prevent the script from dying
foreach($to_list as $row){
if ( ($send_count % $between_delay) == 0 ){
sleep( $send_delay ); //Delays the program execution for the given number of seconds.
}
$address = $row;
if(!empty($address)) {
$mail->AddAddress($address, "User");
$mail->Send();
$mail->ClearAddresses(); //clear address
}
$send_count++;
}
if(!empty($mail->ErrorInfo)) {
// display an error
}
我真的不知道可能是什么问题,但由于某种原因,它在大约 180 号之后停止发送电子邮件。 可能是关于 set_time_limit(300); ??
最佳答案
我不建议将新闻通讯的副本发送到每个单独的电子邮件地址;它会浪费带宽并强制您的脚本发送消息的多个副本。
相反,请考虑使用 SMTP 服务器的密件抄送 (BCc) 功能来发送群发电子邮件。这将使您的 SMTP 服务器能够优化新闻通讯的传送,并且还可以节省您的带宽。
快速查找 PHPMailer API 表明您可以使用 $mailer->AddBCC()
添加密送地址功能。例如,$php_mailer->AddBCC('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97e4f8faf2f5f8f3eed7f2eff6fae7fbf2b9f4f8fa" rel="noreferrer noopener nofollow">[email protected]</a>', 'Joe Somebody');
应该可以。
关于PhpMailer - 无法向大量订阅者发送新闻通讯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14086667/