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@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!

Link to comment
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 <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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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"; 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.