shawnbot Posted January 9, 2008 Share Posted January 9, 2008 My website has a news letter function which currently sends out an email with all addresses in TO: People have requested that the email hide their addresses for privacy/spam, etc reasons. The current code: switch ($_POST['submitBtn']) { case "Send Newsletter": $from = "From: \r\n"; $headers = $from . "Content-type:text/html; charset=iso-8859-1"; $to = split(',',$recipientEmails); $subject = $subjectF; $body = $html_str; foreach ($to as $em){ mail( $em, $subject, $body, $headers); } ?> Can anyone suggest a way to have the email addresses show in Bcc: only? Thanks, Shawn Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/ Share on other sites More sharing options...
p2grace Posted January 9, 2008 Share Posted January 9, 2008 The bcc code would go in the headers. $from = "From: \r\n"; $bcc = "add1@domain.com,add2@domain.com"; $headers = $from.$bcc."Content-type:text/html; charset=iso-8859-1"; Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-434875 Share on other sites More sharing options...
shawnbot Posted January 9, 2008 Author Share Posted January 9, 2008 Thanks for the suggestion but... I tired this way: switch ($_POST['submitBtn']) { case "Send Newsletter": $from = "From: Aradia Fitness <info@test.aradiafitness.com>\r\n"; $bcc = $em; $headers = $from.$bcc."Content-type:text/html; charset=iso-8859-1"; $to = split(',',$recipientEmails); $subject = $subjectF; $body = $html_str; foreach ($to as $em){ mail( $em, $subject, $body, $headers); } No luck....it still shows the email address in TO: Any other ideas? Thanks, Shawn BTW - PHP Nube here Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-434895 Share on other sites More sharing options...
p2grace Posted January 9, 2008 Share Posted January 9, 2008 Did you ever remove it from the $recepientEmails array? Also where's $em coming from when being assigned to $bcc? Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-434898 Share on other sites More sharing options...
shawnbot Posted January 10, 2008 Author Share Posted January 10, 2008 I not sure what you mean by "Did you ever remove it from the $recepientsEmails array?" Can you explain? The $em only appears in this block of code and nowhere else.....I'm not the author so I not sure what the original intent was. I put it in as $bcc=$em becasue the newsletter is being sent to multiple receipients. Thanks, Shawn Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-435502 Share on other sites More sharing options...
p2grace Posted January 10, 2008 Share Posted January 10, 2008 The $em is being declared after the $bcc variable, so there's nothing actually being assigned to the $bcc variable. Also, if you haven't removed the email address from the $recipientEmails array then the system will send them the emails in the $to field. IF you want the email addresses to only show in the $bcc try this. switch ($_POST['submitBtn']) { case "Send Newsletter": $from = "From: Aradia Fitness <info@test.aradiafitness.com>\r\n"; $bcc = $recipientEmails; $headers = $from.$bcc."Content-type:text/html; charset=iso-8859-1"; $subject = $subjectF; $body = $html_str; $to = "test@domain.com"; mail( $to, $subject, $body, $headers); You need to provide the address you want the email sent to, but all of the recipients will now be in $bcc instead of $to Quote Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-435636 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.