如何在以下脚本中添加cc和bcc
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $property_id \n Priority: $priority \n Type: $type \n Message: $message , $proptitle";
$recipient = "myemailid@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='#' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
答案 0 :(得分:0)
您需要设置标题以设置cc和bcc:
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: My Name <myemail@example.com>'. "\r\n";
//Multiple CC can be added, if we need (comma separated);
$headers .= 'Cc: myboss1@example.com, myboss2@example.com' . "\r\n";
//Multiple BCC, same as CC above;
$headers .= 'Bcc: myboss3@example.com, myboss4@example.com' . "\r\n";
mail($to, $subject, $message, $headers);
答案 1 :(得分:0)
$mailheader .= 'Cc: joe@bloggs.com' . "\r\n";
$mailheader .= 'Bcc: john@doe.com' . "\r\n";
根据PHP文档here。
答案 2 :(得分:0)
http://uk3.php.net/manual/en/function.mail.php
您将扩展$ mailheader。
$ mailheader =“From:$ email \ r \ n”。 “密送:someone@example.com'。”\ r \ n“;
答案 3 :(得分:-1)
**First off all you have to concat $recipient with cc and Bcc variable use like this**
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $property_id \n Priority: $priority \n Type: $type \n Message: $message , $proptitle";
$recipient = "myemailid@gmail.com";
$recipient. = "CC: cc@gmail.com\r\n";
$recipient .= "BCC: bcc@gmail.com\r\n";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='#' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>