newsletter optimization help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there Everyone,
 
Below is some code I use to send a newsletter to clients subscribed on
my mailing list.  The problem is I have over
9000+ email addresses in the DB and it takes around 30-45 minutes to
send them with the below code.
 
Can anyone see someway I can optimize it so it sends out the newsletter
any faster?  I've probably gone about
this system the long way, but it works - I just need to find a way to
make it faster :-(
 
Thanks everyone
 
All the best
 
Chris
 
---
 
<?
 
$connection = mysql_connect("localhost","Username","Password") or
die("Couldn't make a connection.");
 
$db = mysql_select_db("WhateverDB", $connection)
            or die("Couldn't select database.");
 
$sql = "SELECT *
        FROM emailtest";
 
$sql_result = mysql_query($sql,$connection)
            or die("Couldn't execute query.");
 
while ($row = mysql_fetch_array($sql_result)) {
            $emailadd = $row["EMail"];
            $emailname = $row["emailname"];
            $emailphone = $row["emailphone"];
            $emailaddress = $row["emailaddress"];
 
$MP = "sendmail -t";
$HT = "<html><body>";
$HT = "</body></html>";
$subject = "$subject";
$NOTE = "$emailtests";
 
$NOTE = str_replace("*email*", "$emailadd", $NOTE);
$NOTE = str_replace("*name*", "$emailname", $NOTE);
$NOTE = str_replace("*phone*", "$emailphone", $NOTE);
$NOTE = str_replace("*address*", "$emailaddress", $NOTE);
 
$TO = "$emailadd"; 
$fd = popen($MP,"w"); 
fputs($fd,"MIME-Version: 1.0\r\n");
fputs($fd,"Content-type: text/html; charset=iso-8859-1\r\n");
fputs($fd, "To: $TO\n"); 
fputs($fd, "From: sales@me.com\n"); 
fputs($fd, "Subject: $subject\n"); 
fputs($fd, "X-Mailer: PHP3\n");  
fputs($fd, "Email: $email\n");
fputs($fd, "$HT");
fputs($fd, "$NOTE");
fputs($fd, "$EHT");
 
}
 
pclose($fd); 
exit; 
 
mysql_free_result($sql_result);
mysql_close($connection);
?>

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux