我正在使用WP 3.3.1
我正在尝试将密件抄送添加到我正在发送的电子邮件的标题中,但没有添加密件抄送。
public $from = "sender@example.com";
public $replyTo = "sender@example.com";
public $bcc = "bccaddress@example.com";
$headers[\'From\'] = "From: ".$this->from;
$headers[\'Reply-To\'] = "Reply-To: ".$this->replyTo;
$headers[\'Bcc\'] = "Bcc: ".$this->bcc;
wp_mail("example@example.com", "My Subject Line" , $html, $headers);
我看过这篇文章,它说这个问题应该在WP 3.2中解决。。。但对我来说,它仍然不起作用。
我正在使用一个名为Papercut 监视正在发送的电子邮件。
Related: wp_mail not recognizing cc and bcc headers
最合适的回答,由SO网友:kaiser 整理而成
您可以尝试如下方式调试输出:
function test_phpmailer_init( $phpmailer )
{
echo \'<pre>\';
var_dump( $phpmailer );
echo \'</pre>\';
return $phpmailer;
}
add_action( \'phpmailer_init\', \'test_phpmailer_init\' );
问题中的代码是正确的,问题出在本地SMTP应用程序上。如果您使用的是本地SMTP服务器(e.x。
Papercut), 它只显示接收者将看到的标题。由于密件抄送地址是隐藏的,您将看不到它们。因此,要检查是否附加了密件抄送地址,可以使用上面列出的函数,该函数将输出邮件。