The Bellow Script will send the exact same message to everyone.
PHP Code:
<?php
//run query to get emails
$query = mssql_query('SELECT Email FROM Account');
$data = array();
while($row = mysql_fetch_array($query)) {
$data[] = $row['email'];
}
//will seperate emails by comma so they can all be sent as once
$to = implode(", ", $data);
//from
$from = "no-reply@yourwebsite.com";
//reply_to
$reply_to = "whodoyouwanttheusertoreplyto@yourwebsite.com";
//Email Headers
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($repy_to) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//Email Subject
$subject = "Test mail";
//Message May Include HTML sense its content type is defined as text/html in header
$message = "<b>Hello!</b><br /> This is a simple email message.";
mail($to,$subject,$message,$headers);
?>
I coded this without testing so ya, but I for that amount of emails I would use, PHPMailer or something that works well with sending bulk emails.
EDIT:
If you want to send customized messages to every user (like username in email) you can do so by,
PHP Code:
<?php
//run query to get emails
$query = mssql_query('SELECT * FROM Account');
//from
$from = "no-reply@yourwebsite.com";
//reply_to
$reply_to = "whodoyouwanttheusertoreplyto@yourwebsite.com";
//Email Headers
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($repy_to) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//I would put subject here if its not different for every user else u can put it in the while() loop.
$subject = "Test mail";
while($row = mysql_fetch_array($query)) {
//Email Subject
$message = "<b>Hello!</b><br /> This is a simple email message. <br />Your username is". $row['UserID'];
mail($row['email'],$subject,$message,$headers);
}
?>