Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我的PHP脚本在从标题设置时不发送电子邮件_Php_Sendmail_Email Headers - Fatal编程技术网

为什么我的PHP脚本在从标题设置时不发送电子邮件

为什么我的PHP脚本在从标题设置时不发送电子邮件,php,sendmail,email-headers,Php,Sendmail,Email Headers,我有一个php脚本,它只在用户注册时发送邮件。 我加入了一些大致如下的内容: $to ='testmail@gmail.com'; $message = 'Hello'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: Website <admin@example.com>\

我有一个php脚本,它只在用户注册时发送邮件。 我加入了一些大致如下的内容:

$to ='testmail@gmail.com';
$message  = 'Hello';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Website <admin@example.com>\r\n";
if($results= mail($to, 'User Registration', 'Test', $headers)) {
  echo 'success';
} else {
  echo 'fail';
}
但电子邮件不会在服务器上发送。当我写下以下一行时:

$headers .= "From: Website <admin@example.com>\r\n";

为什么会发生这种情况?

您是否查看了与您的问题非常相似的答案?

是否检查了垃圾邮件文件夹?检查/var/log/mail.logtry`$headers中的日志。=来自:admin@example.com\r\n;