I have a website and I want to inform all the users (400 in total). To avoid mass mail restrictions on the server, someone helped me out with this script, where it delays the email sending. The problem here, is the $to
, which I don't know what's that for, because the person that helped me forgot somehow about that. How can I fix this script to work well?
I'm in a kind of a hurry, because I don't know when it will be the next time to find that person again soon:D Thank you!
<?php
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
$sql = "SELECT `email`FROM `users`";
$rs = mysql_query($sql) OR die("<pre>\n".$sql."</pre>\n".mysql_error());
while($sel = mysql_fetch_assoc($rs))
{
echo $sel['email'];
echo "<br>";
$headers = "From:site <noreply@site.com>\n";
$headers .= "Content-Type: text/plain;\r\n charset-iso-8859-1\r\n";
$body = "message";
$subject = "subject";
$recipient = $sel['email'];
foreach($to as $recipient)
{
$result = mail($recipient, $subject, $message, $header);
sleep(4);
}
}