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 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 = "[email protected],[email protected]"; $headers = $from.$bcc."Content-type:text/html; charset=iso-8859-1"; 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 <[email protected]>\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 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? 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 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 <[email protected]>\r\n"; $bcc = $recipientEmails; $headers = $from.$bcc."Content-type:text/html; charset=iso-8859-1"; $subject = $subjectF; $body = $html_str; $to = "[email protected]"; 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 Link to comment https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-435636 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.