Jump to content

Sending emails to email addresses in a database


BarneyJoe

Recommended Posts

Can anyone let me know how to go about this?

Basically have a customer sign up form a site, where they can check a box to say they want to receive updates / offers etc.

So what I'm looking to do is enable the site owner to send emails to all those who have done so from the site.

ie get addresses from the email field in the cutomers table where the value of the receiveUpdates field = yes.

How would it typically work exactly - I imagine a form on a page where the owner can type in a title and message, hit a button that actions a php page that retrieves the correct records, and sends out the email.

Cheers.
You have the basic principles correct.

Just make a normal form on the admin page for them to write the email then the php script would look something like this:

$query = mysql_query("SELECT email FROM customers WHERE receiveUpdates = 'Yes'");
while ($info = mysql_fetch_assoc($query)) {
  mail ($info[email], $_POST['subject'], $_POST['message']);
}
echo 'Emails sent.';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.