Not a Member Yet,
Click here to Register

ID: 58
Viewed: 4164
Added: Dec 30, 2001
Snippet uploaded by: snippet
Written By: snippet
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

loops thru mysql database email address and sends mail to each one. Also shows teh result to whom the mail was sent.



// set up a message
$subject = "your subject";
$msg = "I'm looping mail!";
$headers = "From: me@mycompany.comnReply-To:";
// connect to the database and collect addresses
$db = @mysql_connect("yourhost", "use\r\name", "password");
@mysql_select_db("yourdb", $db);
$sql = "select emailaddress from addresstable";
$res = @mysql_query($sql) Or die("Couldn't get addresses.");
// loop through the result set and send mail
While ($email_row = @mysql_fetch_array($res)) {
// get the recipient address
$To = $email_row['emailaddress'];
//send the mail
mail("$to", "$subject", "$msg", "$headers");
//print a confirmation to the screen
echo "mail sent to $to <br>";

//To set a time limit within a script, you use the set_time_limit() //function. You can specify the limit, such as 60 seconds
//, or you can allow it to run until it's absolutely done

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!