function send_email($from, $to, $subject, $message){
$headers = "From: ".$from."\r\n";
$headers .= "Reply-To: ".$from."\r\n";
$headers .= "Return-Path: ".$from."\r\n";
$headers .= "CC: sombodyelse@gmail.com\r\n";
$headers .= "BCC: hiddenemail@gmail.com\r\n";
//set content type to HTML
$headers .= "Content-type: text/html\r\n";
if ( mail($to,$subject,$message,$headers) )
{
header("location:yourdesirepage.php?msg=sent");
}
else
{
header("location:yourdesirepage.php?msg=notsent");
}
}
//Function ends here
$from_email="fromyou@gmail.com";
$to_email="tosomeone@gmail.com";
$subject="Subject of Email";
$message.="";
$message.="Your message here will be look bold when visible to reader";
$message.="Some more message";
$message.="";
send_email($from_email,$to_email,$subject,$message);
In the send_email() function, i used two more headers CC and BCC to send email with CC and BCC in php.
1. $headers .= "CC: sombodyelse@gmail.com\r\n";
CC means Carbon Copy. A comma separated list of more recipients that will be seen by all other recipients.
2. $headers .= "BCC: hiddenemail@gmail.com\r\n";
BCC means Blind Carbon Copy. A comma separated list of more recipients that will not be seen by any other recipients.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment