Jahren Posted August 8, 2008 Share Posted August 8, 2008 Hi guys, my first time here so I'll drop by and say hello I've a question for you (DUH) What's wrong with my snipet of code? An email goes through perfectly but CC and Bcc won't get to destination. //Message is edited above $to = $_POST['Courriel']; $from = "email@clg.qc.ca"; $headers = "From: $from\r\n"; $headers .= "To: $to\r\n"; $headers .= "bcc:email@gmail.com\r\n"; $headers .= "Return-Path: <".$to.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/HTML; charset=ISO-8859-1\r\n"; if(mail($to,$subject,$message,$headers)) edit : removed emails XD idiot me! Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted August 8, 2008 Share Posted August 8, 2008 Well, while I have never used headers in sending emails via my site, I looked at the mail() function in the php manual: http://us3.php.net/manual/en/function.mail.php The only things that I can guess is: a) I'm not sure if the cc & bcc have to have their inital letters capitilized.. here is an example from further down the manual page: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n"; $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n"; $headers .= 'Cc: birthdayarchive@example.com' . "\r\n"; $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); Notice how Cc: and Bcc has its first letters in caps? I'm not sure if this has an effect or not.. I'm not sure if the order of header appending matters (as the above example sends an html email). I would try Cc: as opposed to cc: and same with Bcc.. but other than that.. I'm not sure (again, as I don't use this method). Cheers, NRG Quote Link to comment Share on other sites More sharing options...
nrg_alpha Posted August 8, 2008 Share Posted August 8, 2008 I was reading the comments of the PHP manual page with regards to mail().. I found this statement stood out (not sure if it applies to you or not). "If the Cc or Bcc lines appear in the message body, make sure you're separating header lines with a new line (\n) rather than a carriage return-new line (\r\n). That should come at the very end of the headers." If this does not work, I encourage you to have a look at the mail desciption in the PHP manual and read the comments that follow the descriptions.. some info might be what you are looking for. Cheers, NRG Quote Link to comment Share on other sites More sharing options...
Jahren Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks you for your replies I did try CC, cc Cc and even cC. Same combinaison with Bcc bcc etc.. I read on some forums that having a space after the semi-colomn could be bad. So I tried that too. no luck so far. i'll try moving Bcc up and down and see what it does.. I have a different var for the body message which is $message. I don't mix the two. Well if that's what you meant Quote Link to comment Share on other sites More sharing options...
Jahren Posted August 8, 2008 Author Share Posted August 8, 2008 Allrriiightt xD Moving the bcc statement down did it! $from = "email@clg.qc.ca"; $headers = "From: $from\r\n"; $headers .= "To: $to\r\n"; $headers .= "Return-Path: <".$to.">\r\n"; $headers .= "MIME-Version: 1.0\r\n"; [b]$headers .= "Bcc:email@gmail.com\r\n";[/b] $headers .= "Content-Type: text/HTML; charset=ISO-8859-1\r\n"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.