faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 13 people (77%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

how can 1 send an email to email address in database

Jul 13th, 2000 14:34
Ferdinando Simonetti, Iain Stubley,


persons table structure :
persons_id int not null auto_increment primary key,
persons_name varchar(50),
persons_email varchar(30)
Code
$subject = "Greetings";
$remail = "you@yoursite.com";
mysql_connect("localhost",$user,$pass);
mysql_select_db($database);
$query = "SELECT * FROM persons";
$risult = mysql_query($query);
while ($riga = mysql_fetch_array($risult)) {
mail($riga["persons_email"], $subject ,"Hello ".$riga["persons_name"], 
"From: $remail\nReply-To: $remail");
}
mysql_free_result($risult);