【问题标题】:PHP insert cc into mail function [duplicate]PHP将cc插入邮件功能[重复]
【发布时间】:2012-02-20 21:20:24
【问题描述】:

可能重复:
PHP Mail, CC Field

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

谢谢

$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."\"";

【问题讨论】:

    标签: php email header carbon-copy


    【解决方案1】:

    刚刚对此进行了测试,它按预期工作:

    $headers .= 'Cc: test@test.com\r\n';
    $headers .= 'Bcc: test@test.com\r\n';
    

    我还建议将您的回车和换行移到上一个条目的末尾$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."\"";
    

    希望对你有帮助

    【讨论】:

    • 感谢您的回复。我测试了您的代码并且电子邮件正文有效,但没有发送抄送。任何想法可能是什么原因?
    • 如果您查看原始标头信息,您看到那里的 cc 吗?是否可以发布标题?
    • 我决定从头开始页面重做页面并取下抄送,这是电子邮件:
      --PHP-alt-0603545d439904956b8f20136436ede1 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!!这是简单的文本电子邮件。 --PHP-alt-0603545d439904956b8f20136436ede1 内容类型:文本/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit

      Hello World!

      这是带有 HTML 格式的东西。

      --PHP -alt-0603545d439904956b8f20136436ede1--
    【解决方案2】:

    尝试添加

    $headers .= 'CC: other@url.com' . "\r\n";
    

    【讨论】:

      猜你喜欢
      • 2016-07-09
      • 1970-01-01
      • 2015-06-29
      • 2014-12-21
      • 2016-07-31
      • 1970-01-01
      • 2013-08-16
      • 2016-10-07
      相关资源
      最近更新 更多