BCC in Mail Function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

BCC in Mail Function

Post by PastorHank »

Would someone mind telling me how to include a BCC using the Mail() function or point me towards a tutorial for it? I can get the main 'To' working, but can't find anything about copies, I googled it and get pretty much plain vanilla explainations of the function itself.

thank you
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

BCC is apart of extended header information. It gets passed to the headers argument.
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

thank you
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I'm not sure mail() will handle it correctly though. Bcc is an odd one because it only shows up for the Bcc recipient... even if multiple Bcc addresses are given only the individual recipient address should only be shown in their own email. This means sending the email to each Bcc recipient separately with the additonal headers. Test it first before using it in production and if it doesn't work, either call the mail() function twice or use something that support Bcc correctly.... I'm not even going to say it :P
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

I've been trying it using the extended headers and it doesn't seem to be working, I'm new to php so if there's something out there that I can use in place of the mail() function, I'd appreciate hearing about it.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: read his signature.
PastorHank
Forum Contributor
Posts: 117
Joined: Sat Jun 03, 2006 7:58 am
Location: Texas Hill Country

Post by PastorHank »

Ah, I see said the blind man...
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

For windows servers, like Merak, Sambar, hMailServer, Exchange they seem to follow RFC 1327 (Disclose-Recipients), which states that a Bcc To: should follow the RCPT To:, even if the (Disclose-Recipients) is set to true, it should never be placed in the header! So the mail function will not work for those servers, because they look for blind copy to be passed in the set command only. Unix/Linux most MTA(s) look in the header and if a bcc is found only the address to the BCC would get the message, and the BCC would would be removed. But if (Disclose-Recipients) is set to true, then even the BCC would remain. All MTA(s) that know of, also accept the Bcc To: in the set command.

pif
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

printf wrote:For windows servers, like Merak, Sambar, hMailServer, Exchange they seem to follow RFC 1327 (Disclose-Recipients), which states that a Bcc To: should follow the RCPT To:, even if the (Disclose-Recipients) is set to true, it should never be placed in the header! So the mail function will not work for those servers, because they look for blind copy to be passed in the set command only. Unix/Linux most MTA(s) look in the header and if a bcc is found only the address to the BCC would get the message, and the BCC would would be removed. But if (Disclose-Recipients) is set to true, then even the BCC would remain. All MTA(s) that know of, also accept the Bcc To: in the set command.

pif
Swift copies in all Cc and To addresses as envelope recipients sending just one email and then ajusts the headers for each Bcc recipient sending each one in turn. This should work on all MTAs and is the way it's described in RFC 2821.
Post Reply