PHP 将 cc 插入到邮件函数中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9040866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:01:20  来源:igfitidea点击:

PHP insert cc into mail function

phpemailheadercarbon-copy

提问by rstewart

Possible Duplicate:
PHP Mail, CC Field

可能重复:
PHP 邮件、CC 字段

I am using the following php to send an email. I need to add cc to my email. When I try to insert into header the html message show the raw html. What is the best way to handle a cc?

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

Thanks

谢谢

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

$headers .= "Return-Path: <[email protected]>";

//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

回答by Shawn Barratt

just tested this, and it worked as expected:

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

$headers .= 'Cc: [email protected]\r\n';
$headers .= 'Bcc: [email protected]\r\n';

I would also suggest moving your carriage return and new line to the end of the previous entry to $headers

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

$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: [email protected]\r\n';
$headers .= 'Bcc: [email protected]\r\n';
$headers .= "Return-Path: <[email protected]>\r\n";

// add boundary string and mime type specification
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

hope that helps

希望有帮助

回答by Paul Dessert

Try adding

尝试添加

$headers .= 'CC: [email protected]' . "\r\n";