为什么我的PHP脚本在从标题设置时不发送电子邮件
我有一个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>\
$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;