469,366 Members | 2,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

how to send mail in php with bcc and cc?

hi all,

I am sending e-mail using php code as follows.

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

It is working well. I tested.

Now i want to send mail to more addresses using 'bcc' and 'cc' options.

I need to complete this in php code as much as quickly.

Please help me.

Advance thanks.

Regards

N.Prabhu
Nov 10 '06 #1
4 67128
ronverdonk
4,258 Expert 4TB
Like this, put them in the $headers variable.

[php]
$headers = "From: me@mydomain.com";
$headers .= "\r\nCc: he@$hisdomain.com";
$headers .= "\r\nBcc: her@$herdomain\r\n\r\n";
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
[/php]
Ronald :cool:
Nov 10 '06 #2
Like this, put them in the $headers variable.

[php]
$headers = "From: me@mydomain.com";
$headers .= "\r\nCc: he@$hisdomain.com";
$headers .= "\r\nBcc: her@$herdomain\r\n\r\n";
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
[/php]
Ronald :cool:


Thanks.

It is working nice. We can send mails with bcc and cc.
Nov 17 '06 #3
j4uk3n
2
well i have a problem just by using mail function.
i downloaded this code from a tutorial website, and save it on

c:\apache\htdocs\testsendemail\index.php


here is the code that i downloaded:

<?php

//Check whether the submission is made
if(isset($hidSubmit)){

//Declarate the necessary variables
$mail_to=$txtEmailto;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;

//Check for success/failure of delivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_ from/r/nReply-to:$mail_from"))
echo "<span class='textred'>E-mail has been sent successfully from $mail_sub to $mail_to</span>";
else
echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>";
}
?>

||||
||||
||||
||||
||||

this is the warning message that i received:

Warning: Failed to Connect in c:\apache\htdocs\testsendemail\index.php on line 13
Failed to send the E-mail from to


what should i do?
sorry i'm a total newbie here, just started to learn how to use php.

tQ in advance
Nov 22 '06 #4
ronverdonk
4,258 Expert 4TB
Have you defined the correct email settings in your PHP.INI? If you dont't know, show them.

Ronald :cool:
Nov 22 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by erdem kemer | last post: by
4 posts views Thread by PawelR | last post: by
6 posts views Thread by Retf | last post: by
1 post views Thread by Max | last post: by
3 posts views Thread by crossroadsk | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.