I have a script (php) to read fname, lname and email address from database (Mysql) and send a message to each. The message subjectline and greeting come from a posted value. When I send, the script adds all names to the email and sends a copy to each.:
[INDENT]Greetings John Doe,
Greetings Jane Doe,
vhhvvh hvh hvhvh vh hv h vh vhvhhv h vh vh hv h vh hv h vh vh h vh vh hv!
hvhhv vh vh hv hvh h h h hhhhhh h hhh h h v.
Sincerely,
Me[/INDENT]
The code I am using is:
/* extract email address from database */
$query=“SELECT fname, lname, emailaddress FROM XXXX”;
$result=mysql_query($query);
$num=mysql_numrows($result);
/* mysql_close(); */
$i=0;
while ($i < $num) {
/*convert data to variable */
$fname =mysql_result($result,$i,"fname");
$lname =mysql_result($result,$i,"lname");
$to =mysql_result($result,$i,"emailaddress");
$greet = “$greeting”. mysql_result($result,$i,“fname”)." “.mysql_result($result,$i,“lname”).”, “;
$body = “$greet”.”
“. “$body”;
$headers = “From: $email”;
mail($to, $subject, $body, $headers);
echo $to . " sent <br>”;
$i++;
}
?>
Any suggestions?
I would also like to offer a suggestion… When doing a script like this, do not name it email.php. Unless you have added tags to keep search engines out, spammers can google “email.php” and they are very close to being able to hack into your database.