我想在联系表单中发送BCC电子邮件和收件人。我如何在我的代码中包含BCC?我没有在下面的代码中看到错误,但它不会向BCC或收件人发送电子邮件。如果我删除BCC,它会将您发送给收件人。
$recipient = "xjkfak223@gmail.com";
// Set the email subject.
$subject = "New contact from $name";
// Build the email content.
$email_content = "Name: $name\n";
$email_content .= "Email: $email\n\n";
$email_content .= "Phone: $phone\n\n";
$email_content .= "Message: $message\n";
$email_content .= "$subscribe: Yes\n";
// Build the email headers.
$email_headers = "From: $name <$email>";
$email_headers = "BCC: xy123@gmail.com";
// Send the email.
if (mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(200);
echo "Thank You for Contacting Us.";
}
答案 0 :(得分:1)
您正在覆盖变量
如果添加.=
,它将追加字符串。我想你之间也需要一个逗号新行。
$email_headers = "From: $name <$email>\n";
$email_headers .= "BCC: xy123@gmail.com";