Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP sending email BCC and CC

Posted on 2010-09-16
11
Medium Priority
?
452 Views
Last Modified: 2013-12-12
I have a web form to send email
I use PHP
I send it like this

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: www.mypage.com\r\nReply-To: webmaster@mypage.com";
mail($mymail, $subject, $message, $headers, $address);

I like to add CC and BCC,
how can I add it?
0
Comment
Question by:Braveheartli
[X]
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
  • 5
  • 5
11 Comments
 
LVL 3

Expert Comment

by:Progressed
ID: 33689610
add some rows to your headers!


$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "From: www.mypage.com\r\nReply-To: webmaster@mypage.com";
$headers .= 'Cc: yourCC@adress.com' "\n";
$headers .= 'Bcc: yourBCC@adres.com' "\n";

mail($mymail, $subject, $message, $headers, $address);

this should do the trick
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 33689644
dear Progressed,
it didn't work..
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33689694
$to .= 'recieveremail@domain.com';
$subject .= "whats the subject";

//  send HTML mail
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

// Additional headers
$headers .= 'To: RECIEVERNAME <reciever@domain.com>' . "\r\n";
$headers .= 'From: www.mypage.com <youremail@domain.com>' . "\r\n";
$headers .= 'Cc: CCemail@domain.com' . "\r\n";
$headers .= 'Bcc: BCCemail@domain' . "\r\n";

mail($to, $subject, $message, $headers);


this is what I got and it works perfect!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 33689762
I'm pretty sure the \r\n line terminators are necessary.  Also, "it didn't work.." is not an error message.  It's helpful if you can tell us what the symptoms are.
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33689974
my guess my last reply did the work... no more replies from topicstarter...
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 33690161
Dear Ray_Paseur, and Progressed;

When I write it like this,

$mymail="my1email@mymail.com";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'To: my1email@mymail.com' . "\r\n";
$headers .= "From: mydomain.com\r\nReply-To: webmaster@mydomain.com";
$headers .= 'Cc: my2emai@mymail.com' . "\r\n";
$headers .= 'Bcc: my3emai@mymail.com' . "\r\n";
mail($mymail, $subject, $message, $headers);

I recieve this email my1email@mymail.com on the To section.
but I can not recieve email2 or email3
thank you
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 33690172
on the To section of thecoming email I see this email twice "my1email@mymail.com" but CC and BCC parts are empty..
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 33690199
if I delete
$headers .= 'To: my1email@mymail.com' . "\r\n";
it still sends the email to :

$mymail="my1email@mymail.com";
mail($mymail, $subject, $message, $headers, $address);
0
 
LVL 3

Assisted Solution

by:Progressed
Progressed earned 1000 total points
ID: 33690329
Why are you setting mymail as to in the mail() function?

its: mail($to, $subject, $message, $headers);

in the headers you give YOUR emailadresses in from/cc/bcc in the $header section
0
 
LVL 1

Author Closing Comment

by:Braveheartli
ID: 33690446
thank you,
it wasn't working because of \r\n
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33690473
no problem... glad to be of service :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

719 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