PHP mail and bcc
Moderator: General Moderators
PHP mail and bcc
I need my php script to send me a bcc cant figure it out.
Mail script now:
$to = $_POST[email];
$subject = "Your login info for Blackford County Classmates";
$message = "Hello $_POST[CurrentName],\nYour login details are:\n\nUsername: $_POST[NewUsername]\nPassword: $_POST[p1]\n\nhttp://www.pcdwifi.com/classmates";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
mail($to, $subject, $message, $headers);
Mail script now:
$to = $_POST[email];
$subject = "Your login info for Blackford County Classmates";
$message = "Hello $_POST[CurrentName],\nYour login details are:\n\nUsername: $_POST[NewUsername]\nPassword: $_POST[p1]\n\nhttp://www.pcdwifi.com/classmates";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
mail($to, $subject, $message, $headers);
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: PHP mail and bcc
Add "Bcc: <email address>" to your headers. php mail function
Re: PHP mail and bcc
I have tried that and I can't get it to work. I must be missing something.
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: PHP mail and bcc
They should be at the end of the header and after you've attached your Bcc address(es), end the line with a carriage return rather than just new line to signify the end of the header, using "\r\n".
-Andy
-Andy
Re: PHP mail and bcc
Can you show me with my mail code above???
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: PHP mail and bcc
try this:
Code: Select all
$to = $_POST[email];
$subject = "Your login info for Blackford County Classmates";
$message = "Hello $_POST[CurrentName],\nYour login details are:\n\nUsername: $_POST[NewUsername]\nPassword: $_POST[p1]\n\nhttp://www.pcdwifi.com/classmates";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
// Add this line:
$headers .= "Bcc: email@address.com\r\n";
mail($to, $subject, $message, $headers);
Re: PHP mail and bcc
Tried that again. I had already tried same code. No go.
to: email works but I never receive Bcc
Any other ideas?? I really need this to work, I guess it doesn't have to be a Bcc as long as I recieve the email to. I dont care if they know that I'm receiving it too.
Thank you
to: email works but I never receive Bcc
Any other ideas?? I really need this to work, I guess it doesn't have to be a Bcc as long as I recieve the email to. I dont care if they know that I'm receiving it too.
Thank you
Re: PHP mail and bcc
I forgot to tell you, I have tried
1.| $headers .= "Bcc: email@address.com\r\n";
at the beginning, middle and end of headers. And still can't get it to work. I saw where someone said order can make all the differance.
1.| $headers .= "Bcc: email@address.com\r\n";
at the beginning, middle and end of headers. And still can't get it to work. I saw where someone said order can make all the differance.
Re: PHP mail and bcc
I'm sorry, I told you wrong. When I add that line nobody receives a email.
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: PHP mail and bcc
try
Code: Select all
$headers .= 'Bcc: email@address.com' . "\r\n";Re: PHP mail and bcc
Tried that and same thing no one gets emails.
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: PHP mail and bcc
Try taking all the other headers out and see if it sends the bcc. If it does then add them back in one at a time, trying again each time. One of the other headers may be interfering with the bcc.
Re: PHP mail and bcc
Bill,
Ok, I will try that.
Thank you
Ok, I will try that.
Thank you
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: PHP mail and bcc
Actually, I've never used bcc in the mail function, but I'm not althgether sure it's even supposed to send an email, or whether it merely inserts that indication in the email header. You can get the email sent to you by using multiple "to" addresses. If you're going to do that I would not bother with the bcc header, or I would make it a "cc" header, since the multiple "to" addresses will be visible to the recipient.
Code: Select all
$to = $_POST[email] . ", email.address.com";
Last edited by Bill H on Fri Jan 30, 2009 2:27 pm, edited 1 time in total.
Re: PHP mail and bcc
Took all headers out exept the Bcc. And it still doesn't work. This is strange!