I wrote a script (which I posted) that searches for duplicates and then sends the email, but last time I ran it, it stopped after about 7000 emails. My friends have mentioned batching, but no one really knows how to do it. I usually would look and try to learn myself, but this is somewhat time sensitive. If anyone could help write the batching, or give me detailed instructions on what to do, I would *greatly* appreciate it!
Thanks
Code: Select all
<?php
$host = "localhost";
$user = "user";
$pass = "pw";
$dbname = "db";
mysql_connect($host, $user, $pass);
mysql_select_db($dbname);
$table = "login";
$column = "email";
$emails = array();
$result = mysql_query("SELECT ".$column." FROM ".$table);
$num = mysql_num_rows($result);
//Sets emails array
for($i=0;$i<$num;$i++)
{
$row = mysql_fetch_object($result);
if(!in_array($row->{$column},$emails))
{
$emails[] = $row->{$column};
}
}
//Sends emails
$headers = "From: my@email.com";
//$address = "my@email.com";
$subject = "Subject";
$message = "
Email Here
";
$message = wordwrap($message, 70);
$num_sent = 0;
foreach($emails AS $value)
{
mail($value, $subject, $message, $headers);
echo "$value \n";
$num_sent++;
}
echo "$num_sent";
?>