Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:40:09+00:00 2026-06-16T04:40:09+00:00

I have a PHP script which sends an e-card to multiple recipients in function

  • 0

I have a PHP script which sends an e-card to multiple recipients in function calls (takes an array of comma-separated email addresses and mail()s to each one individually). However, when looking at the received email, each client can see the other addresses that the email was sent to, making me believe they are all being sent in one email, despite the separate mail() calls. Here is my current code:

<?php
$headers  = "From: ".$_POST['email']."\r\n"; 
$headers .= "Content-type: text/html\r\n";
$array=explode(",", $_POST['sendto']);
for ($i = 0; $i < count($array); ++$i) {
    mail(trim($array[$i]), "Happy Holidays!", $body, $headers);
}
?>

How do I fix this so that the recipient can only see their email address in the “to” field?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:40:11+00:00Added an answer on June 16, 2026 at 4:40 am

    What you want to use is the BCC field.

    • https://en.wikipedia.org/wiki/Blind_carbon_copy

    Code:

    <?php
    
    $_POST['email'] = str_replace(array("\n", "\r"), '', $_POST['email']);
    $_POST['sendto'] = str_replace(array("\n", "\r"), '', $_POST['sendto']);
    
    $headers = "From: " . $_POST['email'] . "\r\n"
             . "Content-Type: text/html\r\n"
             . "BCC: " . $_POST['sendto'] . "\r\n";
    mail($_POST['email'], 'Happy Holidays!', $body, $headers);
    
    ?>
    

    Send the email to the sender, but BCC the recipients. Also I removed \r and \n chars from the BCC and FROM field otherwise will allow mail header injection attack. Make sure to do the same to $body.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which similar to this: foo.php class Foo { function Foo()
I have a AJAX script which sends a POST request to PHP with some
I have this script which sends an email for users to activate their accounts
I have a typical mail.php script, which uses the mail() function. After the user
I have a php script which sends user a mail if his purchase is
I have an Android application which sends json data to PHP script. The PHP
I have a PHP script which opens a socket connection(using fsockopen) and takes about
I have a function which sends specified form data to a php processing page.
So I have a PHP script which takes in piped emails, appends a footer
I have a script which sends an email to myself from a contact page:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.