Email to database

From: Date: Fri, 05 Sep 2003 11:08:02 +0000
Subject: Email to database
Groups: php.general 
Request: Send a blank email to php-general+get-161737@lists.php.net to get a copy of this message
Hi I am using a PHP / MySQL combination to send an email to all users in a table. When I run the script, say address1 in the resultset is enda@nightsol.net, address2 is enda2@nightsol.net & address3 is enda3@nightsol.net ­ When I run the script, mail is sent to address1,address2 & address3. Problem is I get copies of all mails sent to the first address pulled from the table. Any help appreciated. Thanks Enda -- ============================================= PHP Code ============================================= $result1=mysql_query("select DISTINCT first_name,last_name,email_address from <database> WHERE 1 ORDER BY id",$link); //--------------------------------------------------------------------- while($row = mysql_fetch_array($result1)) { $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: Website <emailaddress>\r\n"; $headers .= "To: $row[email_address]\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: Normal\r\n"; $headers .= "X-Mailer: MyWebsite"; $subject = "$subject"; $message = "<html><head><title>aaa</title></head><body bgcolor=ffffff>aaa</body></html>"; mail($to, $subject, $message, $headers) or print "Could not send mail to customer"; print "<br><font size=1><font color=cccccc>mail sent to </font><b>$row[email_address]</b>"; } - + - + - + - + - + - + - + - + - + - + - + - + - Enda Nagle +353 86 168 0774 enda@nightsol.net www.nightsol.net - + - + - + - + - + - + - + - + - + - + - + - + -

« previous php.general (#161737) next »