私はここで大きな問題を抱えています!すべての購読者 (約 1200) にニュースレターを送信する必要があります。問題は、150 ~ 180 人の購読者にのみニュースレターを送信することです。PhpMailer() クラスを使用してすべての購読者にニュースレターを送信するスクリプトを php に実装しました。
毎月 3 万通のメールを送信できる MailJet のプランを購入したので、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);に関するものでしょうか。??