Hi all,
I got an application which sends e-mail to an array of users --> $email_to = {email_to} .
{email_to} can have also more that 2000 addressee
I would like to insert a sleep(1800) within the routing of 100 email to avoid blocking in e-mail sending but I need to split the array of {email_to} into batches of 100 email at time.
I don’t know how achieve it…
More or less I have this parameters to use.
$email_to = {email_to}; // To email array
$nr_email_to = $count = count($email_to); //Total Nr of email to send
$nr_mail_batch = ceil($nr_email_to/100); // Nr of batches to send
sc_mail_send([glo_mail_smtp_server], [glo_mail_smtp_user], [glo_mail_smtp_pass], $mail_from , $mail_from , {subject}, $message, “H”, $email_to , $type_copy , [glo_mail_smtp_port],[glo_mail_smtp_ssl], $email_attach);
Probably it’s completly wrong… as approch becouse I’m not a programmer
Here , I suppose, I need to have another internal loop or similar that send 100 email at time splitting the ‘$email_to’ array correctly otherwise I send all mails everytime … ;-((
$x=1;
while($x<=$nr_mail_batch)
{
???
sc_mail_send([glo_mail_smtp_server], [glo_mail_smtp_user], [glo_mail_smtp_pass], $mail_from , $mail_from , {subject}, $message, “H”, $email_to , $type_copy , [glo_mail_smtp_port],[glo_mail_smtp_ssl], $email_attach);
???
sleep(1800)
$x++;
}
if you have a better solution it will be very appreciated
Googling I saw also array_chunk($array, 100); but I don’t know if it could be helpful or not.