Link to home
Start Free TrialLog in
Avatar of BR
BRFlag for Türkiye

asked on

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?
Avatar of Progressed
Progressed

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
Avatar of BR

ASKER

dear Progressed,
it didn't work..
$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!
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
my guess my last reply did the work... no more replies from topicstarter...
Avatar of BR

ASKER

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
Avatar of BR

ASKER

on the To section of thecoming email I see this email twice "my1email@mymail.com" but CC and BCC parts are empty..
Avatar of BR

ASKER

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);
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BR

ASKER

thank you,
it wasn't working because of \r\n
no problem... glad to be of service :)