Jump to content

php mail from MySQL Mailing List


jeliot

Recommended Posts

I'm trying to write a script to collect email addresses from MySQL and send a generic email (possible a template
with the ability to insert custom body) to everyone on the list.

Here's what I've got so far

<?
//conects to the data base
$db_host = "mysql";
$db_user = "user";
$db_pwd = "password";
$db_name = "test";
mysql_connect($db_host, $db_user, $db_pwd) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

//gets the data
$data = mysql_query("SELECT * FROM test_list")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
$to = $info['email'];
$subject = "Ggap Show Reminder";
$body = "This is a test email for Ggap New Show Reminders";
$headers = "From: [email protected]\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
</?

obviously not a working script yet.........I KNOW i do need to somehow keep the header of the email from showing other on the list.

Any Suggtions are welcome
Thanks
Link to comment
https://forums.phpfreaks.com/topic/6526-php-mail-from-mysql-mailing-list/
Share on other sites

[!--quoteo(post=361436:date=Apr 3 2006, 10:09 PM:name=sanfly)--][div class=\'quotetop\']QUOTE(sanfly @ Apr 3 2006, 10:09 PM) [snapback]361436[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Check out the data about the mail function in the [a href=\"http://php.inspire.net.nz/manual/en/function.mail.php\" target=\"_blank\"]manual[/a]
[/quote]

Well I've been to the php manual and then to my yahoo host and back to the manual again and I've dwindled my scipt down to this

<?
$mail = "[email protected]";
$subject = "test";
$msg = "test email";
$header = "From: [email protected]";
mail($mail,$subject,$msg,$header);


?>

Thanks for the advice I've got the send mail part working now the part i dread is getting the info from the db and sending a mass email to everyone
It seems like I may have to read a whole book on php just to use a few of the abbilities of php but I hope not...................

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.