Member Avatar for stephen_UK

Hi,
I am generating an automatically email successfully using the code below, where all the email addresses are contained in the variable $to.

How do I change the code below to send all of these emails as a bcc so that their email addresses are not disclosed to one another?

If necessary I can just have my email address in $to and all the bcc addresses in $blindcopy

// $to contains approx 30 email addresses
$subject = '*****NEW RECORD ADDED TO THE DATABASE*****';
$message = $id;
$headers = 'From: stephen@xxx.org' . "\r\n" .
           'Reply-To: stephen@xxx.org' . "\r\n" .
           'Content-type: text/html; charset=iso-8859-1\r\n'.
           'X-Mailer: PHP/' . phpversion();        
 mail($to, $subject, $message, $headers);

Many thanks to all those that took time to respond.

Stephen

Member Avatar for stephen_UK

Thanks Simon, I had already seen that before posting, but I cannot see an example anywhere of using variables containing many email addresses, to send as a bcc.
I can't find the correct syntax.
Stephen

Maybe look into some mass emailers like newsletter scripts that you can modify? Here is one for 5 bucks on codecanyon

http://codecanyon.net/item/yrmail-simple-mailer/73608?WT.ac=search_item

Lemme find it but i know theres a really nice, good looking, well functioning newsletter script that you can easily modify

Ok i found it - http://net.tutsplus.com/articles/news/build-a-newsletter-system-with-php-and-mysql-new-plus-tut/

You need a premium subscription to the site, which is 9$ but thats a great deal because they have SO many resources..

You can also just buy it from their tutorials market for 3$ http://marketplace.tutsplus.com/item/build-a-newsletter-system-with-php-and-mysql/125622?WT.ac=search_item

But its going to end up costing 5$ because you don't have any pre-paid credit on your account. So i suggest either buying it from their market or getting a membership...


Sorry it thats super confusing

Member Avatar for stephen_UK

I have subsequently found this old post from 2008, stating that as an anti-spam measure the use of variables in bcc and cc is blocked.
The 2008 posting is pasted below for info:
Posted 14 May 2008 - 12:32 AM
Ok, got a fun one. I have a basic contact form that sends an email with the php mail() function. It works fine with all headers except cc or bcc, below is the code. I have tested it on a server other than ASO and it works fine with cc or bcc headers. Seems like someone else would have ran into this before. Thanks

I am running PHP 4.4.8 (wow I gotta get on that )

CODE
<?php
$msgTo = "msgTo@email.com";
$msgSubject = "Crabby Carbon Copies";
$msgContent = "This is the message, that won't get seen on an ASO server. :)";

$bcc = "blindcarbon@email.com";

$msgHeaders = "To: $msgTo\r\n";
$msgHeaders .= "From: no-reply@email.com\r\n";
$msgHeaders .= "Bcc: $bcc\r\n";
$msgHeaders .= "X-Mailer: PHP".phpversion();

$success = mail($msgTo, $msgSubject, $msgContent, $msgHeaders);
___________________________________________________________________
Hey, I got an answer on this from ASO support. I swear I'm not that impatience, I just thought it would be good to have it on here for others' reference.

Here is what ASO support said:
QUOTE
CC and BCC headers when using php's mail() function are blocked by the suhosin security module. This is intentional. If you need a script that sends such headers please use SMTP to send the mail as this allows us to keep better track of outgoing mail for the purpose of identifying and stopping spam.

Stephen

Hi,

i know this thread is old but, i've encountered the same problem and managed to solve it simply.

I don't know if it's gonna work everywhere but it seems to...

I just write my BCC variable like this :
$bcc = "<firstmail@isp.com>,<secondmail@isp.com>,<thirdmail@isp.com>";

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.