Not a Member Yet,
Click here to Register

ID: 58
Viewed: 4130
Added: Dec 30, 2001
Version:
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.

<!---Head--->
none

<!---Body--->


 <?
// set up a message
$subject = "your subject";
$msg = "I'm looping mail!";
$headers = "From: me@mycompany.comnReply-To: someoneelse@mycompany.com";
// 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
set_time_limit(60)
//, or you can allow it to run until it's absolutely done
set_time_limit(0)


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 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!