【问题标题】:Why is my PHP script not sending emails when set from header为什么我的 PHP 脚本在从标头设置时不发送电子邮件
【发布时间】: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


【解决方案1】:

您看过smtp configuration for php mail 的答案吗?这与您的问题非常相似?

【讨论】:

    猜你喜欢
    • 2021-01-31
    • 2011-09-16
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    • 2011-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多