Mail list out of addresses in DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Mail list out of addresses in DB

Post by synical21 »

Is it possible to grab every users email from the database, then create a mailing list with them?
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: Mail list out of addresses in DB

Post by Grizzzzzzzzzz »

yes
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Mail list out of addresses in DB

Post by synical21 »

Any chance you could extend that answer? :P
limitdesigns
Forum Commoner
Posts: 25
Joined: Sat Feb 06, 2010 9:05 pm

Re: Mail list out of addresses in DB

Post by limitdesigns »

You could make a form for administrators for a message to be sent to all users, and then you can get all user rows in a while loop and send an email with the content of that form to each user's email address.

Code: Select all

 
<?php
$message = $_POST['message'];
$from_header = "From: you@yourdomain.com";
$subject = "Newsletter";
$result = mysql_query("SELECT `email` FROM `users`");
while($row = mysql_fetch_array($result)) {
     mail($row['email'], $subject, $message, $from_header);
}
?>
 
synical21
Forum Contributor
Posts: 150
Joined: Tue Jul 28, 2009 8:44 am
Location: London UK

Re: Mail list out of addresses in DB

Post by synical21 »

Oooo of course so simple, i will try that now
Post Reply