Hi:
I need some advice on how to handle this function of emailing contents of an online form to multiple recipients in a database.
I have an online inquiry form that collects info from a visitor. Upon submission, an email containing the info in a formatted email goes to all active email addresses from the database.
Ideas? Thanks so much in advance!
Email to Multiple Recipients from DB
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
well the most simplest way (without opening sockets) would be something like:
something along these lines would work.....
Code: Select all
// pseudo code
$query = "SELECT email FROM mytable";
$result = mysql_query($query) or die (mysql_error());
$array1 = mysql_fetch_array($result, MYSQL_ASSOC);
// now mail the first user we'll later do the rest
mail("$array1[email]", "Subject Here", "Message HERE");
// now loop
while ($array2 = mysql_fetch_assoc($result))
// and send
mail("$array2[email]", "Subject Here", "Message HERE");Code: Select all
// more psuedo code
$result = mysql_fetch_array(mysql_query("select email from table"));
for ($i=0;$i<=count($result);$i++) {
mail($result[$i], $subject, $message);
}