Re: Loop though email list

From: Date: Tue, 14 Aug 2001 21:17:38 +0000
Subject: Re: Loop though email list
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-62704@lists.php.net to get a copy of this message
for a file i would do something like this: <? $file = file ("addressfile.txt"); foreach ($file as $address) mail ($address, "subject", "message", "From: you@yourhost.com"); ?> for the mysql db it would be something like this (this is probably a little off): <? $mysql = mysql_pconnect ($server, $username, $pw); $res = mysql_query ("select * from addresses", $mysql) or die ("something went bad"); while ($row = mysql_fetch_array ($res)) { mail ($row["address"], "subject", "message", "From: you@yourhost.com"); } ?> I hope this helps. I'm sure it probably has a syntax error or something but you get the point. :-) Welcome to the happy world of php! - Dan On Tue, 14 Aug 2001, Erich Kolb wrote: > I am a total newbie, so please forgive the simplicity! > > I have a huge list of email addresses in a text file and also in a MySQL DB > that I would like to use PHP to loop through and send an email to each one > of them. How do I loop through a text file using each email in the txt file > as a seperate email address and send a message to that address? Or would it > be easier to just do it from a MySQL DB? If so, How?? > > > --

« previous php.general (#62704) next »