当我将 $headers 数组指定为时,我无法通过 PHP 邮件函数发送电子邮件
$headers = array (
'From' => "[email protected] /cdn-cgi/l/email-protection",
'Content-type' => "text/html;charset=UTF-8"
);
or
$headers=array(
'From: "[email protected] /cdn-cgi/l/email-protection',
'Content-Type:text/html;charset=UTF-8',
'Reply-To: "[email protected] /cdn-cgi/l/email-protection'
);
这是代码
<?php
$email = '[email protected] /cdn-cgi/l/email-protection';
$headers=array(
'From: "[email protected] /cdn-cgi/l/email-protection',
'Content-Type:text/html;charset=UTF-8',
'Reply-To: [email protected] /cdn-cgi/l/email-protection'
);
$msg= 'This is a Test';
mail($email, "Call Back Requert Confirmation", $msg, $headers);
?>
你能告诉我为什么会发生这种情况吗?我该如何解决这个问题?
如果您想发送$headers
通过数组,然后你需要添加\r\n
到每个标头值的末尾并将数组转换为string
.
你的代码应该是:
$headers = array(
'From: <[email protected] /cdn-cgi/l/email-protection>',
'Content-Type:text/html;charset=UTF-8',
'Reply-To: <[email protected] /cdn-cgi/l/email-protection>'
);
$headers = implode("\r\n", $headers);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)