Hi Everyone. I have the bare bones of a php script which mails everyone who signs up for the news letter of a club night (held on a mysql database). The code is below. What I am wondering is, when I call it, it displays the first email address as sent then displays the next ones in blue with the error message. Even though it displays an error it does actually send the email (right now I’m testing with 3 variations of my own address so all emails are received. Can anyone help with getting this code displaying sensible feedback rather than nonsense?
Also, Is 10 seconds a bit too long? With just over a thousand members, it might take a long time (2 hours 48 mins exactly if my math is correct.)
Thanks in advance
Graham
[CODE]<?php
session_start();
if (!session_is_registered(“username”)) {
header( ‘Location: login script address’) ;
} else {
$user=”xxx”;
$host=”localhost”;
$password=”xxx”;
$database=”xxx”;
mysql_connect(“$host”, “$user”, “$password”) or die(‘Unable to connect:’ . mysql_error());
mysql_select_db(“$database”) or die(‘Unable to connect:’ . mysql_error());
//this is a bulk emailer
//use carefully!!!!
$sql = mysql_query(“SELECT * FROM users”);
$num_rows = mysql_num_rows($sql);
while ($row = mysql_fetch_array($sql)) {
// take weight off the server CPU by waiting 10 seconds between each mailout.
sleep(10);
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= “From: [email protected]”;
if (!mail($row[“email”],
$subject = “UFREAK E-Flyer”,
$message = ”
<html>
<body>
<center><p><img src=’absolute path of flyer’/></p></center>
<body>
</html>”, $headers)) {
echo “<FONT FACE=VERDANA, ARIAL SIZE=2 Color=Blue>E R R O R <FONT Color=Blue> : Mail has not been sent to ” . $row[“email”] . “</FONT><BR>n”;
} else {
echo “<FONT FACE=VERDANA, ARIAL SIZE=2>” . $row[“email”] . “</FONT><BR>n”;
}
}
}
?>