PHP mail headers problem
I'm trying to use BCC fields in some PHP email. My code is as below:
$to = "myemail@email.com";
$subject = 'Subject here';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "From: <myemail@email.com>\r\n";
$headers开发者_如何学JAVA .= "Bcc: <myemail@email.com>\r\n";
//send the email
if (!mail($to, $subject, 'body', $headers)){
echo "Error";
}
What I've discovered is that if I include the bcc field in my headers the script just errors and the email is not sent. I've looked everywhere for the syntax and my understanding is that what I have is correct, but clearly something is wrong! Thanks
CC and BCC headers when using php's mail() function are blocked by the suhosin security module.
I found this in: http://forums.asmallorange.com/topic/11501-php-mail-cc-bcc-headers/
I cannot reproduce it, works for me
http://sandbox.phpcode.eu/g/12908.php
check your mailserver
What line is the error on. Maybe it's good to use all double quotes or all single quotes also, and not mixed up. You can also remove the concat dot in the MIME line.
精彩评论