Jump to content

Recommended Posts

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

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

Link to comment
https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-434895
Share on other sites

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

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

Link to comment
https://forums.phpfreaks.com/topic/85243-emailing-bcc/#findComment-435636
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.