【问题标题】:Bcc: using custom Wordpress mail.php contact form密件抄送:使用自定义 Wordpress mail.php 联系表
【发布时间】:2015-06-13 19:42:17
【问题描述】:

我正在尝试让我们的 Wordpress 网站中的自定义联系表单在将填写好的表单发送给收件人时向我发送密件抄送。表单的 $headers 部分如下所示:

        $headers  = 'Content-type: text/html; charset=iso-8859-1'."\r\n";
        $headers .= 'From: '.$email;

我已经尝试使用这个来实现密件抄送:

        $headers  = 'Content-type: text/html; charset=iso-8859-1'."\r\n";
        $headers .= 'From: '.$email;
        $headers .= 'Bcc: '.myemail@email.com;

...但它只发送给标准收件人,而不是密件抄送地址。

你能看出我做错了吗?非常感谢!

【问题讨论】:

  • 这种方法非常脆弱——您没有应用这些标头所需的任何编码,因此很可能会因某些用户输入而中断。这就是为什么像 PHPMailer(Wordpress 使用)这样的库存在的原因,但是你绕过了所有这些。
  • 我最终使用的是:$headers = "From: .get_bloginfo('name').' <'.get_option('admin_email').'>'.\r\nReply-to: $email\r\nBcc: myemail@email.com";

标签: wordpress email phpmailer bcc


【解决方案1】:

试试$headers的数组形式-

$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: '.$email;
$headers[] = 'Bcc: myemail@email.com';

【讨论】:

  • 注意编辑 - 如果密件抄送电子邮件不是 PHP 变量,它应该只是字符串的一部分。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-10
  • 2012-10-22
  • 2012-09-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多