Parse Error in my Mail Function -UPDATED
| From: | Anti-Blank | Date: | Fri, 07 Jun 2002 17:53:32 +0000 |
| Subject: | Parse Error in my Mail Function -UPDATED | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-101146@lists.php.net to get a copy of this message | ||
Sorry I was too sleepy to realize the Red and BOLD wouldn't come through on the list. Here is
the message again but I was smart enough this time to comment those section.
All right I've used the help that I've gotten before about this and edited this function
of code I have. Initially the code was meant to mail out a post to every email that was listed in
the database. The problem was that it sent all the emails in the TO: section of the email. Now
being that I didn't want to give out the emails of everyone on the list, I wanted to instead
hardcode the TO: section and then drop all of the emails from the database into the BCC: section.
The problem being now I am getting a parse error on lines 30. Included are the original code and my
version(which is spitting the error). If anyone can offer any insight as to what I'm missing
or messing up I should say it would be most appericated.
ORIGINAL SECTION OF MAIL FUNCTION:
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 = "";
$query = mysql_query("SELECT * FROM members");
while ($member = mysql_fetch_array($query)) {
if ($to == "") {$to = $member['email'];}
else {$to .= ", " . $member['email'];}
}
$from = "from: " . $setting_mail_email;
mail ($to, $setting_site_name, $mailpost, $from) or $emailsuccess = "Failure sending
email.";
if ($emailsuccess == "") {$emailsuccess = "Email Sent Successfully.";}
}
MY MODIFIED SECTION (I've commented the sections I changed and also the line with the parse
error:)
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);
//Everything Below here is where my changes occur
$to = "anti@anti-blank.com";
$from = "from: " . $setting_mail_email;
$bcc = "bcc: ";
$query = mysql_query("SELECT * FROM members");
while ($member = mysql_fetch_array($query)) {
if ($bcc == "") {$bcc = $member['email'];}
else {$bcc .= ", " . $member['email'];}
}
$headers = $from . "\r\n" . $bcc . "\r\n"
//The Next Line is where I'm getting the parse Error at
mail ($to, $setting_site_name, $mailpost, $headers) or $emailsuccess = "Failure sending
email.";
if ($emailsuccess == "") {$emailsuccess = "Email Sent Successfully.";}
}
Thanks for any insight that anyone might have.