Jump to content

Mail Bcc/Cc function not working as expected


DJMurtz

Recommended Posts

I've been trying to get the mail function working with the Cc and Bcc headers. Basicly what I want is an admin to be able to send out an email to all users in the database. However, I do not want all those email addresses to be shown in the To list like this:

email1@test.com, email2@test.com, email3@test.com, etc

I wanted only to show the email of the user in the To list. Now I can accomlish this by doing a while loop with a new email address in each mail send. However, I was under the impression that the Bcc header exsisted to solve this problem.

I figured, that if I put the first email address it gets from the database in the standard place of the mail() funcion, and put the rest of the email addresses in the Bcc header it would all work out, like this:

[code]        while($aSendToAddresses = mysql_fetch_array($qSendToAddresses)) {
            $sSendToAddresses .= ', ' . $aSendToAddresses['email'];
        }
        $sSendToAddresses = substr($sSendToAddresses, 2);
        $sSendToFirstAddress = explode(', ', $sSendToAddresses);
        $sSendToAddresses = str_replace($sSendToFirstAddress[0], '', $sSendToAddresses );
        $sSendToAddresses = substr($sSendToAddresses, 2);
        $sSendToAddresses = 'Bcc: ' . $sSendToAddresses . "\r\n";
        
        mail($sSendToFirstAddress[0], $_POST['mailtitle'], $_POST['mailmessage'], $sSendToAddresses);[/code]

However, the result of this script was that indeed all the emails where send, and indeed not all the users where listed in the 'to' list. But the problem was that each email address had the email of the first receipe (defined in $sSendToFirstAddress) in the 'To:' line...

Can anyone help me out to fix this? or is the only solution a while loop of the mail function
Link to comment
Share on other sites

[!--quoteo(post=367029:date=Apr 21 2006, 12:49 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Apr 21 2006, 12:49 AM) [snapback]367029[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The simple solution is to set the 'to' address to your own address and put ALL recipients in the BCC group.
[/quote]

That would still mean that all users see my email in the To address but I want it to show only their own address?
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.