hello everyone,
i have created a mailing list tool that sends out mass emails to email addresses that are pulled out from a mysql database.
the problem is that there are over 1000 email addresses that it loops through and the script seems to time out after sending to the first 200 users or so.
is there a solution for sending out mass emails? this database of emails could potentially grow to be over 10,000.
here's the code i have so far:
<?php
$subject = $HTTP_POST_VARS["subject"];
$subject = stripslashes($subject);
$content_1 = $HTTP_POST_VARS["content_1"];
$content_1 = htmlentities($content_1, ENT_QUOTES);
$content_1 = stripslashes($content_1);
$content_1 = "<font face=\"arial\"> ". $content_1 ." </font>";
$SQL = "SELECT EmailAddress FROM $db";
if(!$result = mysql_query($SQL)) die("Query died for $SQL");
while($row = mysql_fetch_array($result))
{
$EmailAddress2[] = $row["EmailAddress"];
}
$subject2 = $subject;
$headers = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .="From: name<name@name.com>";
$mailbody = stripslashes($content_1);
$max= count($EmailAddress2);
for ($i=0; $i < ($max); $i++)
{
if(!mail($EmailAddress2[$i], $subject2, $mailbody, $headers)) die ('Email not sent');
}
?>
any help would be greatly appreciated!!
thanks in advance
karren
i have created a mailing list tool that sends out mass emails to email addresses that are pulled out from a mysql database.
the problem is that there are over 1000 email addresses that it loops through and the script seems to time out after sending to the first 200 users or so.
is there a solution for sending out mass emails? this database of emails could potentially grow to be over 10,000.
here's the code i have so far:
<?php
$subject = $HTTP_POST_VARS["subject"];
$subject = stripslashes($subject);
$content_1 = $HTTP_POST_VARS["content_1"];
$content_1 = htmlentities($content_1, ENT_QUOTES);
$content_1 = stripslashes($content_1);
$content_1 = "<font face=\"arial\"> ". $content_1 ." </font>";
$SQL = "SELECT EmailAddress FROM $db";
if(!$result = mysql_query($SQL)) die("Query died for $SQL");
while($row = mysql_fetch_array($result))
{
$EmailAddress2[] = $row["EmailAddress"];
}
$subject2 = $subject;
$headers = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .="From: name<name@name.com>";
$mailbody = stripslashes($content_1);
$max= count($EmailAddress2);
for ($i=0; $i < ($max); $i++)
{
if(!mail($EmailAddress2[$i], $subject2, $mailbody, $headers)) die ('Email not sent');
}
?>
any help would be greatly appreciated!!
thanks in advance
karren