homepage Welcome to WebmasterWorld Guest from 54.197.110.151
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Bcc not working in email script
caffinated



 
Msg#: 4383600 posted 6:03 pm on Nov 4, 2011 (gmt 0)

Hello

Here is a script I am using for emailing subscribers:

<?php
$to = 'someone@address.com';
$subject = 'discount etc';
$message = '

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8" />
</head>

<body>
{content is included here}
</body>
</html>
';

$headers = 'From: me@me.com' ."\r\n";
$headers .= 'MIME-Version: 1.0' ."\r\n";
$headers .= 'Content-type: text/html; charset=UTF8' ."\r\n";
$headers .= 'Bcc: person1@address.com, person2@address.com, person3@address.com' ."\r\n";

mail($to, $subject, $message, $headers);
?>


Everything works fine, except non of the BCC addresses are working.

When I check the inbound email for the $to: recipient, all of the headers are being processed and received...all but the bcc addresses.

Any clues why?

PS. Yes I know there are out-of-the-box packages out there, that's not the solution I'm looking for thanks.

 

rainborick

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4383600 posted 6:58 pm on Nov 4, 2011 (gmt 0)

Looks OK to me at first glance. But if you're grasping for straws, you might test the script on a different server just to be sure that the host isn't blocking 'Bcc' fields to reduce SPAM.

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 4383600 posted 10:59 am on Nov 5, 2011 (gmt 0)

Maybe a security issue? Some (shared) servers prevent emails from being BCC'd to addresses on another domain. But you should get an error logged if this is the case of the form...

Warning: mail(): SMTP server response: 554 <joe@anotherdomain.com>: Recipient address rejected: Relay access denied

caffinated



 
Msg#: 4383600 posted 12:39 pm on Nov 8, 2011 (gmt 0)

many thanks guys. I'm looking into the security matter then.

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4383600 posted 1:01 pm on Nov 8, 2011 (gmt 0)

unless I am misunderstanding

When I check the inbound email for the $to: recipient


you're looking for the Bcc in the received email? that would sort of go against the point of bcc if you could see them there.

put another of your addresses in the bcc and see if you receive the email.

caffinated



 
Msg#: 4383600 posted 1:19 pm on Nov 8, 2011 (gmt 0)

Yeah Jatar_k that's what I already did. None of the bcc emails arrived - hence my original question. But sometimes the obvious is missed, so thanks for covering that off.

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4383600 posted 1:51 pm on Nov 8, 2011 (gmt 0)

yeah, sorry, just checking

you could also play with the order, it often makes a difference

try moving your bcc right after your from

<added>you could even try just using \n instead of \r\n

playing around with headers and line endings is sometimes a help, especially if there are no errors

also make sure all the addresses/servers are good

also adding more headers may be paart of the issue as your receiving mail server could just be burning it if it sees it as spam

so many points where an email could fail

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved