Jump to content


Photo

php mail from MySQL Mailing List


  • Please log in to reply
2 replies to this topic

#1 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 04 April 2006 - 12:35 AM

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: jason@bandsite.com\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

#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 04 April 2006 - 02:09 AM

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]
If you're not part of the solution, you're part of the precipitate

#3 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 04 April 2006 - 05:40 PM

[!--quoteo(post=361436:date=Apr 3 2006, 10:09 PM:name=sanfly)--][div class=\'quotetop\']QUOTE(sanfly @ Apr 3 2006, 10:09 PM) View Post[/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 = "me@mydomain.com";
$subject = "test";
$msg = "test email";
$header = "From: mealso@mydomain.com";
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...................




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users