PHP邮件功能,删除了errors-to标头的必要性


PHP mail function, remove the neccessity for errors-to header

我在一个服务器上,需要在使用PHP mail()函数时设置errors -to标头。流行的应用程序如Wordpress没有指定这个标题(至少不是所有地方)-所以电子邮件没有发送(相反,我收到一条消息,说发送电子邮件出错,因为它缺少标题)。服务器主机说这不是他们可以为系统改变的东西。我无法访问.ini文件。我能做点什么吗?

可以,通过使用普通mail()-函数设置所需的邮件头:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "'r'n" .
    'errors-to: webmaster@example.com' . "'r'n" .
    'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>

在wordpress中,你可以重载wp_mail()函数来包含标题