Register  |  Login

Question Details    

   Question

Time: 14:40 - Sep 04, 2006     Asked by: dustPuppy      Status: Answered      Points: 50   

How do I set a BCC address when sending email in PHP?

How do I set a BCC address when sending email in PHP?
I suppose I have to set the header, but how should it look?

Ask a New Question

Become a Quomon Expert

Current Categories

 

Other Questions Needing Answers


   

Answer Discussion
Answer Discussion
Answer Summaries
Answer Summary
 
Bcc is set by adding something like this to the additional headers parameter:

"Bcc: copyme@example.com\r\n"

This should work from PHP 4.3 onwards.

Expert:

jgivoni

Date:

Sep 04, 2006

Time:

20:38

 

Votes: Good (0) | Bad (0)
Login to rate this answer

If you don't feel like writing the headers yourself, you might find it easy to use the PHPMailer class. It's quite professional and allows cc, bcc, multiple addresses, smtp authentication, attachments and so on.

You will need to download the classes from http://phpmailer.sourceforge.net/ and then use some code like this :

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "smtp1.site.com;smtp2.site.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "jswan"; // SMTP username
$mail->Password = "secret"; // SMTP password

$mail->From = "from@email.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@site.com","Josh Adams");
$mail->addBCC("joe@site.com","Joe Tailer");

$mail->Subject = "Here is the subject";
$mail->Body = "This is the body";


if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";

Expert:

redcharcoal

Date:

Sep 05, 2006

Time:

10:36

 

Votes: Good (0) | Bad (0)
Login to rate this answer

thanks a lot, that's a great help.
Especially the phpmailer class makes things easier for me. Thanks for the example, redcharcoal.

Expert:

dustPuppy

Date:

Sep 05, 2006

Time:

10:52

 

Votes: Good (0) | Bad (0)
Login to rate this answer

AddBCC will work only on Win32 :(

Expert:

ramanvemman

Date:

Jun 24, 2008

Time:

01:56

 

Votes: Good (0) | Bad (0)
Login to rate this answer

Question Answered

This question has been answered, and points have been rewarded to the following experts:

jgivoni: 25
redcharcoal: 25

You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.

 
No summaries have been submitted yet. Want to be the first?



Respond to this question:

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

 

New User

  Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:


Forgotten Password

   

"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it


All Questions


Language Options

English:

www.quomon.com

Español:

www.quomon.es

Quomon Blog

blog.quomon.com

Sponsors

Questions and Answers Software
Real Estate Postcards
Marketing Fulfillment