PHP将cc插入邮件功能

rst*_*art 2 php email header carbon-copy

可能重复:
PHP Mail,CC Field

我使用以下php发送电子邮件.我需要在我的电子邮件中添加cc.当我尝试插入标题时,html消息显示原始html.处理cc的最佳方法是什么?

谢谢

$headers = "From: $from_email\r\nReply-To: $from_email";

$headers .= "Return-Path: <info@premierinspectiontn.com>";

//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
Run Code Online (Sandbox Code Playgroud)

小智 15

刚试过这个,它按预期工作:

$headers .= 'Cc: test@test.com\r\n';
$headers .= 'Bcc: test@test.com\r\n';
Run Code Online (Sandbox Code Playgroud)

我还建议将回车和新行移到上一个条目的末尾 $headers

$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: test@test.com\r\n';
$headers .= 'Bcc: test@test.com\r\n';
$headers .= "Return-Path: <info@premierinspectiontn.com>\r\n";

// add boundary string and mime type specification
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
Run Code Online (Sandbox Code Playgroud)

希望有所帮助