Jump to content

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: 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
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 = "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...................
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.