Jump to content

[SOLVED] PHP mail - CC and Bcc problem


Jahren

Recommended Posts

Hi guys, my first time here so I'll drop by and say hello :P

 

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 protected]";
	$headers = "From: $from\r\n";
	$headers .= "To: $to\r\n";
	$headers .= "bcc:[email protected]\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!

Link to comment
https://forums.phpfreaks.com/topic/118719-solved-php-mail-cc-and-bcc-problem/
Share on other sites

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 <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\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

 

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

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

Allrriiightt xD

Moving the bcc statement down did it!

 

	$from = "[email protected]";
	$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 protected]\r\n";[/b]
	$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\r\n"; 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.