Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

PHP sending email BCC and CC

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
Braveheartli
Asked:
Braveheartli
  • 5
  • 5
2 Solutions
 
ProgressedCommented:
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
 
BraveheartliMarketingAuthor Commented:
dear Progressed,
it didn't work..
0
 
ProgressedCommented:
$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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Ray PaseurCommented:
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
 
ProgressedCommented:
my guess my last reply did the work... no more replies from topicstarter...
0
 
BraveheartliMarketingAuthor Commented:
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
 
BraveheartliMarketingAuthor Commented:
on the To section of thecoming email I see this email twice "my1email@mymail.com" but CC and BCC parts are empty..
0
 
BraveheartliMarketingAuthor Commented:
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
 
ProgressedCommented:
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
 
BraveheartliMarketingAuthor Commented:
thank you,
it wasn't working because of \r\n
0
 
ProgressedCommented:
no problem... glad to be of service :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now