【问题标题】:Why php mail() function displays subject two times (localhost)为什么 php mail() 函数显示主题两次(本地主机)
【发布时间】:2015-10-08 10:52:02
【问题描述】:

我正在使用XAMPP,当我使用 PHP mail() 函数发送电子邮件时,主题出现了两次(例如“你好,你好”)。

PHP 代码:

$from="me@gmail.com"; 
$to="you@gmail.com";
$subject="hello";
$message="this doesn't work nicely";
$headers = 'From: '.$from."\r\n".
        'Subject: '.$subject."\r\n".
         'Mime-Version: 1.0'."\r\n";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $headers);

有人知道解决办法吗?

【问题讨论】:

  • 只需将其从$headers 中删除即可。

标签: php email subject


【解决方案1】:

看起来 $headers 是这里的问题:

$from="me@gmail.com";

$to="you@gmail.com";

$subject="hello";

$message="this doesn't work nicely";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message,);

【讨论】:

  • 但是为什么我的原始代码可以在其他服务器上正常工作,但不能在 localhost 上工作?是否应该在 php.ini 或 sendmail.ini 文件中进行一些编辑?
  • 当您尝试通过 localhost 发送时收到的错误消息是什么?
  • 如果你安装了一个 SMTP 服务器并配置 localhost 监听 25 端口。有人推荐 Postfix。
  • 没有出现错误信息,因为电子邮件已发送,但由于某种原因,主题显示了两次。
  • 好的。回到你原来的问题,你现在可以从本地主机发送电子邮件了吗?
猜你喜欢
  • 2011-07-17
  • 2022-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-10
  • 2020-06-13
  • 2014-11-09
  • 2011-06-21
相关资源
最近更新 更多