Forum Moderators: coopster

Message Too Old, No Replies

PHP Mail Script

Pull addresses from MYSQL

         

piskie

9:40 am on Sep 11, 2006 (gmt 0)

10+ Year Member



I need a reasonably secure php mail script that will select the appropriate Email Address from a MYSQL Table.

Has anybody got any suggestions or recommendations please

barns101

10:04 am on Sep 11, 2006 (gmt 0)

10+ Year Member



This simple code will do it:


<?php
// Define the text of your email
$message = 'Your email body text.';

// Connect to your database, grab the email addresses and send the message
mysql_connect('localhost','user','pass');
mysql_select_db('database');
$result = mysql_query ("SELECT * FROM `table`");
while ($row = mysql_fetch_array($result))
{
// Assuming that there is a field named "email" in your table
mail($row[email], 'Subject', $message, 'From: You <you@example.com>');
}
?>