
October 5th, 2003, 12:44 PM
|
|
Registered User
|
|
Join Date: Aug 2002
Posts: 28
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
sending multiple emails/data repeating itself
I have a simple db table named 'mail' which has a mailid, email, fname, and lname. I am running a query to pull the mailid and email and then am looping through the result set mailing each one. It sends the emails fine but the link in the body of the message that allows the recipient to remove themselves from the database is repeating itself in every message. For example, there are 4 people in the db. Every mail sent out contains 4 messages saying 'You have received this message because you have visited our site....blah, blah.' and each one is pointing to a differnt mailid.
I've stripped out the relevant code below.
PHP Code:
$sender_email = 'Karen\'s Site';
$header = "From: \"".$sender_email."\" <".$sender_email.">\n";
$header .= "Reply-To: ".$sender_email."\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=iso-8859-1\n";
$header .= "X-Priority: 3\n";
$sql = "select mailid, email from mail";
$res = mysql_query($sql);
while($myrow = mysql_fetch_array($res))
{
$email_addr = $myrow['email'];
$id = $myrow['mailid'];
$message .= "<p><br><font face=arial size=1>You have received this message because you have visited our site\n";
$message .= "If you feel this is a mistake or would just like to unsubscribe,\n";
$message .= "please <a href=\"http://mysite.com/unsub.php?mailid=" .$id. "&action=delete_mail\">Click Here</a></font>\n";
mail("$email_addr", "$subject", $message, $header);
}
Any suggestions?
Thanks 
|