申し訳ありませんが、時間どおりに返信するために別の投稿をする時間がありました。
このプロセスの目的は、一定時間後にメールがWebサイトのユーザーに送信されることです。
特定の時間にphpファイルを実行するcronがあります
たとえば、毎週月曜日の午前8時
* 8 ** 1 php-f / $ filepath ()
このphpファイルは何千ものメールを送信しますが、すべてを午前8時から継続的に送信するのではなく、毎分30通のメールを午前8時から送信したいと思います。
あれは:
08:00->0-30メール
08:01->30-60メール
08:02->60-90メール...など
cronの起動は午前8時に1回実行されるため、php sleep関数を使用して数分の間一時停止することを考えましたが、コマンドを尊重しません。システムは失敗し、ロックされます。私のCの経験では、睡眠機能は常に正しく機能します。
発送時に30通のメールを送信し、カウンターでループを終了するように設定しました
***** php-f /$filepath ()
そのため、システムに毎分ファイルを実行するように強制します。
私のコード
$res = $admin->array_mixed(); //Array with all mails address
$send_per_min=30;
$send = 0;
foreach ($res as $r){
$mails->AddAddress("$r['invitacion_email']");
.
.
.
$mails = new PHPMailer(true);
$mails->Mailer = "smtp";
.
.
.
if($mails->Send()){
$send++;
$log_OK .= $mail." Send!!! \n";
}else{
$log_KO .= $mail." Failed!!! \n";
}
if ($send == $send_per_min){//With this line I checked that after making 30 shipments out of the loop until the next minute the cron rerun
//I want to replace it with a sleep that once sent 30 mails, wait until the next minute. In this way, you could set the cron at a specific time
break;
}
}//End for
以前の投稿( https://stackoverflow.com/questions/15393432/sending-emails-with-phpmailer-partitioned )よりも明確になっていることを願っています。
コミュニティへのご挨拶。
Pd-私の悪い英語でごめんなさい