Mailing Function
I've got a script that I'm trying to modify. This section is suppose to take the updates that I put in and mail them out to the mailing list. The problem is the original function piece would drop every email on the list into the TO field of the mail going out. Well I don't want to give away all the emails of my users so I wanted to drop them all into BCC. Though apperently, as I'll admit, I don't know exactly what I'm doing and now all my emails get dropped into the SUBJECT field.
If anyone can see what I'm doing wrong and could help me clear this up it would be appericated, or if there is a much easier way to go about what I'm trying to do to this that would also be helpful. I've included that section I modified below.
function postNews () {
// Get input from form, and members name.
global $cookie_username, $headline, $post, $mail;
// check to see if we should send email.
if ($mail == "yes") {
global $setting_site_name, $setting_site_url, $setting_mail_email;
$fhandle = fopen("newstemps/mailpost.tmp", "r") or die("could not open newstemps/mailpost.tmp");
$mailpost = fread($fhandle, filesize("newstemps/mailpost.tmp"));
fclose ($fhandle);
$mailpost = $mailpost;
$mailpost = str_replace("{setting_site_name}", $setting_site_name, $mailpost);
$mailpost = str_replace("{setting_site_url}", $setting_site_url, $mailpost);
$mailpost = str_replace("{setting_mail_email}", $setting_mail_email, $mailpost);
$mailpost = str_replace("{post_poster}", $cookie_username, $mailpost);
$mailpost = str_replace("{post_headline}", $headline, $mailpost);
$mailpost = str_replace("{post_date}", date("M d, Y", time()), $mailpost);
$mailpost = str_replace("{post_post}", $post, $mailpost);
$to = "antisocial@livejournal.com";
$bcc = "";
$query = mysql_query("SELECT * FROM members");
while ($member = mysql_fetch_array($query)) {
if ($bcc == "") {$bcc = $member['email'];}
else {$bcc .= ", " . $member['email'];}
}
$from = "from: " . $setting_mail_email;
mail ($to, $bcc, $setting_site_name, $mailpost, $from) or $emailsuccess = "Failure sending email.";
if ($emailsuccess == "") {$emailsuccess = "Email Sent Successfully.";}
}
If anyone can see what I'm doing wrong and could help me clear this up it would be appericated, or if there is a much easier way to go about what I'm trying to do to this that would also be helpful. I've included that section I modified below.
function postNews () {
// Get input from form, and members name.
global $cookie_username, $headline, $post, $mail;
// check to see if we should send email.
if ($mail == "yes") {
global $setting_site_name, $setting_site_url, $setting_mail_email;
$fhandle = fopen("newstemps/mailpost.tmp", "r") or die("could not open newstemps/mailpost.tmp");
$mailpost = fread($fhandle, filesize("newstemps/mailpost.tmp"));
fclose ($fhandle);
$mailpost = $mailpost;
$mailpost = str_replace("{setting_site_name}", $setting_site_name, $mailpost);
$mailpost = str_replace("{setting_site_url}", $setting_site_url, $mailpost);
$mailpost = str_replace("{setting_mail_email}", $setting_mail_email, $mailpost);
$mailpost = str_replace("{post_poster}", $cookie_username, $mailpost);
$mailpost = str_replace("{post_headline}", $headline, $mailpost);
$mailpost = str_replace("{post_date}", date("M d, Y", time()), $mailpost);
$mailpost = str_replace("{post_post}", $post, $mailpost);
$to = "antisocial@livejournal.com";
$bcc = "";
$query = mysql_query("SELECT * FROM members");
while ($member = mysql_fetch_array($query)) {
if ($bcc == "") {$bcc = $member['email'];}
else {$bcc .= ", " . $member['email'];}
}
$from = "from: " . $setting_mail_email;
mail ($to, $bcc, $setting_site_name, $mailpost, $from) or $emailsuccess = "Failure sending email.";
if ($emailsuccess == "") {$emailsuccess = "Email Sent Successfully.";}
}
