Bulk emails using PHPmailer fails

226
February 08, 2018, at 11:18 PM

I've been using phpmailer to send bulk emails and it works successfully for upto 300 clients. I have a Database of 3000 people and it doesnt pass the limit. Even though it does they are listed as spam sometimes. Very time consuming, taking 30 minutes to mail 300 clients.

Is there a possible way to make make it quick and send emails to 3000 people. I'm using shared hosting too

Thanks

Here's the code:

if(($sendbulk==1)&&($porc!='')) {

    set_time_limit(600); // 
    // actual begining o fhte a_bulk email code
    if($porc==1) {
        $sql=mysql_query("SELECT c_fname, c_lname, c_email FROM client_".$f_id." WHERE c_status='1' ORDER BY c_lname") or die(mysql_error());
    } elseif($porc==2) {
        $sql=mysql_query("SELECT p_fname, p_lname, p_email FROM provider_".$f_id." WHERE p_available='1' ORDER BY p_lname") or die(mysql_error());
    }
    require ('../includes/class.phpmailer.php');
    $mail                = new PHPMailer();
    //$body                = file_get_contents('contents.php'); moved to loop

        $mail->IsSMTP();
        $mail->Host          = 'xxxxx;
        $mail->SMTPAuth      = true;
        $mail->SMTPKeepAlive = true;                  // SMTP connection will not close after each email sent, reduces SMTP overhead
        $mail->Host          = 'xxxxxxx';
        $mail->Port          = 2525;
        $mail->Username      = 'xxxxx';
        $mail->Password      = 'xxxxx';
        $mail->SetFrom(''.xxxx', 'xxxxxxx');
        $mail->AddReplyTo(''.xxxxx', 'xxxxx');

    $mail->Subject       = $subject;
    $ecount=0;
    $count=0;
    while ($row = mysql_fetch_array($sql)) {
      if($porc==1) {
          $fname=$row['c_fname'];
          $lname=$row['c_lname'];
          $email=$row['c_email'];
      } elseif($porc==2) {
          $fname=$row['p_fname'];
          $lname=$row['p_lname'];
          $email=$row['p_email'];
      }
      if($email!='') { 
          $ecount=$ecount+1; //count how many were sent
          $count=$count+1; //count how many were processed
          $body             ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                                <html>
                                <head>
                                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                                  <title>'. $subject.'</title>
                                </head>
                                <body class="page page-a_id-563 page-template-default gspm custom-header header-image header-full-width content-sidebar foodie-pro" itemscope="itemscope" itemtype="http://schema.org/WebPage">
                                  <div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
                                    <p>'. $fname.' '.$lname.'</p>
                                    <p>'. $message.'</p>
                                  </div>
                                </body>
                                </html>';
          $mail->AltBody    = 'To view the message, please use an HTML compatible email viewer!';
          $mail->MsgHTML($body);
          $mail->AddAddress($email, $fname.' '.$lname);

          if(!$mail->Send()) {
                $error1 .= "Mailer Error (" . str_replace("@", "&#64;", $email) . ') ' . $mail->ErrorInfo . '<br />';
          } else {
                //echo "Message sent to :" . $fname.' '.$lname . ' (' . str_replace("@", "&#64;", $email) . ')<br />';

                $query=("INSERT INTO mailing_list_".$f_id." VALUES ('', '$fname', '$lname', '$email', '1', '$porc', '$nowdate')");
                $result=mysql_query($query);
            }
          // Clear all addresses and attachments for next loop
          $mail->ClearAddresses();
          $mail->ClearAttachments();
          if($count==50) {
                //code to pause process for email throttling
                sleep(60); //set at
                $count=1;
          }
    }
    }
    //end of a_bulk email code

}
Rent Charter Buses Company
READ ALSO
Kirby Get URL from Blueprint

Kirby Get URL from Blueprint

Sorry, but I can't find anything about that topic

289
Redirect subscribers if they are in Woocommerce shop page

Redirect subscribers if they are in Woocommerce shop page

There is a lot of plugins available that makes this possible, but they are not for free, so I'm actually trying to restrict shop, checkout and cart page, just for people registered as customers, I test this code below on functionsphp file:

217
Apache update resulting in images not uploading using PHP

Apache update resulting in images not uploading using PHP

We had an Apache update done by our hosting company which resulted in all media file transfer queries not working, for example image uploadingEverything was working absolutely fine prior to this

190
My html part is not being executed when i open the file through xampp [on hold]

My html part is not being executed when i open the file through xampp [on hold]

My html part is not being executed when i open the file through xamppall the images are not shown and all the hyperlinks stop working

173