Mass mailing - PHPMailer

0

Good morning!

I have an email marketing system and I'm having trouble making a newsletter shot for a large list of contacts. (Understand large list as: a list containing over 1000 emails.)

If I take the shot for less than 1000 emails, shooting happens perfectly. If there are more than 1000, it does not send for everyone, even sending up to half the list.

I contacted Localweb, the server that hosts my accounts and where I authenticated SMTP, and they informed me that it could be a possible loss of packages during the sending.

My code looks in the database (SQL Server) within a for loop for all mail from the list that has been selected for the trigger and then sends it there. One consideration: sending is performed by a Cron Job that runs every 5 minutes.

Can anyone help me? Any idea what that might be?

My shipping code:

    $mail = new PHPMailer();
    $mail->setLanguage('br');
    $mail->CharSet='utf-8';   
    $mail->IsSMTP(); 
    $mail->Host = "xxx";
    $mail->SMTPAuth = true;
    $mail->Username = 'xxx';
    $mail->Password = 'xxx';
    $mail->SMTPSecure = 'tls'; 
    $mail->Port = 587; 
    $mail->From = $email; (variável que vem do banco de dados)
    $mail->FromName = $fantasia; (variável que vem do banco de dados)
    $mail->SMTPOptions = array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
    );

    for($z=0; $z<count($bcc); $z++){

        if($html == '1'){
            $topo = recebe um código html específico;
              $rodape = recebe um código html específico;
              $texto2 = recebe um código html específico, concatenando as variáveis $topo e $rodape - newsletter que será enviada; 
        }else{
            if($topo == '1'){
              $topo = recebe um código html específico;
              $rodape = recebe um código html específico;
            }else{
                $topo = recebe um código html específico;
              $rodape = recebe um código html específico;
            }

            $texto2 = recebe o código html específico, concatenando $topo e $rodape - newsletter que será enviada; 
        }

        $mail->AddAddress($bcc[$z]['Email']);
        $mail->IsHTML(true);
        $mail->Subject  = $tit; (variável vinda do banco)
        $mail->Body = $texto2;
        $mail->AltBody = $texto2;
        $enviado = $mail->Send();
        $mail->ClearAllRecipients();
        $mail->ClearAttachments();

    }
    
asked by anonymous 24.10.2017 / 16:32

2 answers

0

The script may be terminating the process before time, try using the command:

set_time_limit(0);

Documentation: link

It defines how long the script will run, when you set the time to 0, this time gets unlimited.

It can also be finalized by consuming too much processing, try to put a time between 100 and 100 email for example using sleep.

sleep(10);

This time is in seconds

    
24.10.2017 / 17:20
1

I think it's a limitation of the hosting itself. Usually a third party service is used for this type of sending, such as: mailgun, mailchimp among others. They have a very easy-to-integrate API and have free plans.

I hope I have helped.

    
24.10.2017 / 16:47