DJMurtz Posted April 20, 2006 Share Posted April 20, 2006 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:[email protected], [email protected], [email protected], etcI 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 Quote Link to comment https://forums.phpfreaks.com/topic/7991-mail-bcccc-function-not-working-as-expected/ Share on other sites More sharing options...
AndyB Posted April 20, 2006 Share Posted April 20, 2006 The simple solution is to set the 'to' address to your own address and put ALL recipients in the BCC group. Quote Link to comment https://forums.phpfreaks.com/topic/7991-mail-bcccc-function-not-working-as-expected/#findComment-29176 Share on other sites More sharing options...
DJMurtz Posted April 21, 2006 Author Share Posted April 21, 2006 [!--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? Quote Link to comment https://forums.phpfreaks.com/topic/7991-mail-bcccc-function-not-working-as-expected/#findComment-29279 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.