I had time on another post to respond on time, sorry.
The purpose of the process is that after a definite time mails are sent to users of a website.
I have a cron that executes a php file at a specific time
For example, every Monday at 8:00 a.m.
* 8 ** 1 php-f / $ filepath ()
This php file sends thousands of emails but instead of sending all continuously from 8am, I want send 30 mails per minute from 8:00 eg
That is:
08:00 -> 0-30 mails
08:01 -> 30-60 mails
08:02 -> 60-90 mails ... etc.
Since launching the cron runs once at 8am I thought about using php sleep function to pause between minutes but does not Respect the command, the system fails and is locked. In my experiences with C the sleep function always work correctly.
I set the shipping to send 30 mails when and exit the loop with a counter
***** php-f /$filepath ()
and so force the system to run the file every minute.
My code
$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
I hope you have been more clear than in the previous post (https://stackoverflow.com/questions/15393432/sending-emails-with-phpmailer-partitioned).
Greetings to the community.
Pd-Sorry for my bad English