PHP mail() - add a BCC recipient

Posted on 2009-04-07
Last Modified: 2012-08-13
How can I add a BCC recipient?
$to      = '';
$subject = 'Subject';
$message = mailClean(str_replace("\n","#nl#",$orderEmail));
$headers = 'From: My Name <>' . "\r\n" .
    'Reply-To:' . "\r\n" .
    'X-Mailer: WEBSITE ' . time();
    mail($to, $subject, $message, $headers);

Open in new window

Question by:hankknight
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

brittonv earned 400 total points
ID: 24086586
$headers .= 'Bcc:' . "\r\n";

For referenece:
LVL 14

Assisted Solution

shobinsun earned 50 total points
ID: 24086612

For example:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To:>' . "\r\n";
$headers .= 'From:>' . "\r\n";
$headers .= 'Cc:' . "\r\n";
$headers .= 'Bcc:' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 50 total points
ID: 24087276
just modify your header like this,

$headers = 'From: My Name <>' . "\r\n"  .
 'Cc:' . "\r\n' . 
 'Reply-To:' . "\r\n" .
    'X-Mailer: WEBSITE ' . time();
    mail($to, $subject, $message, $headers);

Open in new window


Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question