Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail header question

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
Ok, so my mail is great and wonderful and happy... except my bcc and cc headers don't bcc or cc, or get mail to those recipients at all really.

Here's what I'm doing...
Code:
$emails = get_emails();
$to = $emails["to"];
$bcc = $emails["bcc"];
$message = &quot;<HTML><HEAD></HEAD><font color = yellow>Still testing</font></HTML>&quot;;
$from=&quot;xxxx&quot;;

$headers = &quot;From: $from\n&quot;;
$headers .= &quot;Reply-To: $from\n&quot;;
$headers .= &quot;X-Mailer: PHP/&quot;.phpversion().&quot;\n&quot;;
$headers .= &quot;Content-type: text/html; charset=iso-8859-1\n&quot;;
$headers .= &quot;Bcc: $bcc\n&quot;;

$result=mail($to,&quot;Mail Test&quot;, $message, $headers);
echo $result;


$result ends up equaling 1, $to gets the email just fine, but the $bcc does not. And I've echo'd it to make sure that $bcc is a normal and good and valid email.

Any input, or shall I just write the loop and send everyone their own copy?

-Rob
 
The problem is that BCC: isn't a real header like &quot;To:&quot; or &quot;From:&quot; -- it isn't sent with the email (what would be the point?). It's more of a mail client macro.

This from the online manual (The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. PHP < 4.3 only supported the Cc: header element (and was case-sensitive). PHP >= 4.3 supports all the mentioned header elements and is no longer case-sensitive.

Want the best answers? Ask the best questions: TANSTAAFL!
 
You know, I must've read that line a half dozen times and said... good thing I have > 4.3... however, I have 4.2.3... woo hoo for morning coding.

Thanks for helping me see what I was staring at.

-Rob
 
I am using php 4.3.1 but CC and BCC are still not working...Please help me if you have this worked out.

Thanks
-farzana
 
I did upgrade to 4.3.1 but I never bothered going back and implementing my BCC code... I'm still looping and sending to everyone.

-Rob
 
but i will have like 600 emails or more, i think looping with with high number will not be efficient...
 
and using the CC field would be cruel to the recipients. I was just letting you know so that you weren't waiting too long for my resolution, as I don't have a tested one. Just the one from above which is still commented out in my code.

-Rob
 
well CC is not working either ;) i don't remeber if it woked for me in older php version or not. and even if it did i could not use it...because of the reason you mentioned.

Thanks for your help
 
I got both CC and BCC working....here is my syntax:

$headers .= &quot;From: $sender\r\n&quot;;
$headers .= &quot;Return-Path: fdost@bla.com\r\n&quot;;
$headers .= &quot;Cc:fdost@bla.com\r\n&quot;;
$headers .= &quot;Bcc:fdost@bla.com\r\n&quot;;

I used to have a space after : in cc and bcc, after removing that it worked, I also set the return path to my address to see the failiur messages...actually that is what helped me debuge my code.

Farzana
 
I have a 900+ email list, so looping with a while was killing the server.

I set

Bcc: Name <address>, Name2 <adress2>\r\n

And stuck it in the headers.

I think it takes a while (especially with beasts like mine), as I haven't received my copy, but other people say they have theirs.

Good stuff.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top