Hi,
Ok what I am trying to do is email everyone who has registered so far on the site. There are about 10000 records, but only about 30 have registered yet.
Below is my code:
<?php
$landps = array("mydb", "localhost", "myuser", "mypass");
$database = $landps[0];
$host = $landps[1];
$username = $landps[2];
$password = $landps[3];
$table = 'users';
$Subject = trim ($Subject);
$Message = trim ($Message);
$URL = 'http://www.mysite.com/admin/';
mysql_connect ($host,$username,$password) or die ("Failed login.");
mysql_select_db ($database) or die ("Failed to access db.");
$Message = nl2br($Message);
$Message = preg_replace("/((http(s?)://)|([url]www.[/url]))([S.]+)b/i",
"<a href=\"http$3://$4$5\"
target=\"_blank\">$2$4$5</a>", $Message);
$Message = preg_replace("/([w.]+)(@)([S.]+)b/i",
"<a href=\"mailto:$0\">$0</a>",
$Message);
$From = 'Chris <chris@yduk.net>';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $From\r\n";
$result = mysql_query("SELECT email FROM users WHERE registered = 1");
while ($row = mysql_fetch_array($result))
{
$recipient = $row['email'];
mail ($recipient, $Subject, $Message, $headers) or die ("mail failure.");
}
header("Location: $URL");
?>
Now the problem is it seems to do something for a few seconds, but then it says "mail failure"... I know it sends some emails, but not all of them.
Is it timing out or what? I don't understand why it won't work, the code looks fine to me.
Any of you pros got an idea?
Cheers,
Chris