【发布时间】:2015-05-29 00:04:09
【问题描述】:
我有一个 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.log中的日志 -
试试 `$headers .= "From: admin@example.com\r\n";
标签: php sendmail email-headers