我这里有一个大问题! 我需要向所有订阅者发送简报(大约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); ??
的事情答案 0 :(得分:2)
我不建议将电子报的副本发送到每个电子邮件地址;它会浪费带宽并强制您的脚本发送邮件的多个副本。
相反,请考虑使用SMTP服务器的盲目复制(BCc)功能发送群发电子邮件。这将允许您的SMTP服务器优化新闻稿的传送,它也将为您节省带宽。
快速查找PHPMailer API表示您可以使用$mailer->AddBCC()
函数添加BCc的地址。例如,$php_mailer->AddBCC('somebody@example.com', 'Joe Somebody');
应该有效。
答案 1 :(得分:1)