Im having a big problem here! I need to send a newsletter to all my subscribers (around 1200) The thing is that it only sends the newsletter to 150-180 of them. I have a script implemented in php that uses the PhpMailer() class to send the newsletter to all the subscribers.
I purchased a plan in MailJet that allows me to send 30 thousand emails per month, so Im using their SMTP host to send the newsletter.
Here is my script:
$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
}
I really dont know what may be the problem but for some reason it stops sending emails after the number 180 approximately. Could it be something regarding the set_time_limit(300); ??