PHP mail() script and sending multiple users.
Posted: Thu Dec 28, 2006 7:21 am
Good morning (at least at the time of this post
,
I have created a newsletter-style script and have everything up and running except this part. What this is intended to do is when an administrator posts a press release, it will send multiple emails to individual recipients that meet the database criteria.
My problem appears to be with the loop function. For some odd reason, I am having a total brainfart when it comes to this function. If anyone can help me I would greatly appreciate it (and give you 1,000 points to spend on your ego.
)
I have created a newsletter-style script and have everything up and running except this part. What this is intended to do is when an administrator posts a press release, it will send multiple emails to individual recipients that meet the database criteria.
My problem appears to be with the loop function. For some odd reason, I am having a total brainfart when it comes to this function. If anyone can help me I would greatly appreciate it (and give you 1,000 points to spend on your ego.
Code: Select all
<?php
//Connection statement
require_once('../../Connections/MCSO_Website.php');
// begin Recordset
$colname__mr = '-1';
if (isset($_GET['id'])) {
$colname__mr = $_GET['id'];
}
$query_mr = sprintf("SELECT * FROM mediareleases WHERE id = '%s'", $colname__mr);
$mr = $MCSO_Website->SelectLimit($query_mr) or die($MCSO_Website->ErrorMsg());
$totalRows_mr = $mr->RecordCount();
$query_checkemail = sprintf("SELECT * FROM mailinglist WHERE verified = '1' AND active = '1'");
$checkemail = $MCSO_Website->SelectLimit($query_checkemail) or die($MCSO_Website->ErrorMsg());
$totalRows_checkemail = $checkemail->RecordCount();
// multiple recipients
$to = "webmaster@marionso.com";
// subject
$subject = 'Marion County Sheriff\'s Office - New Media Release';
// message
$message = '
<font face="Verdana, Arial, Helvetica, sans-serif" size"2">
Hello,
<br><br>
A new Media Release - "'.$mr->Fields('title').'" - has been posted on our website, <a href="http://www.marionso.com">http://www.marionso.com</a>.
<br><br>
You may click this link (<a href="http://www.marionso.com/mediareleases.php">http://www.marionso.com/mediareleases.php</a>) to visit our website and view the latest Media Releases.
<br><br>
--------------------------------------------------------------------------------<br>
You are receiving this email because you subscribed to our Media Releases Mailing List. To unsubscribe, please click here (<a href="http://www.marionso.com/mediareleasesml.php">http://www.marionso.com/mediareleasesml.php</a>) and follow the instructions.</font>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: no-reply@marionso.com';
do {
$headers .= 'Bcc: '.$checkemail->Fields('email').'' . "\r\n";
} while ($checkemail->Fields = mysql_fetch_assoc($checkemail));
// Mail it
mail($to, $subject, $message, $headers);
?>