php mail() 额外的_headers
每当我指定 addtional_headers 参数时,我似乎都无法使用 PHP 的 mail() 函数发送任何邮件。
<?php
mail('[email protected]', 'subject', 'message here');
?>
工作正常,但
<?php
$headers = 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers .= 'From: Me <[email protected]>' . PHP_EOL;
mail('[email protected]', 'subject', '<h1>message</h1>', $headers);
?>
根本不传递任何消息。
有什么原因会导致这种情况发生吗?
I can't seem to send any mail using PHP's mail() function whenever I specify the addtional_headers parameter.
<?php
mail('[email protected]', 'subject', 'message here');
?>
Works fine, but
<?php
$headers = 'MIME-Version: 1.0' . PHP_EOL;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . PHP_EOL;
$headers .= 'From: Me <[email protected]>' . PHP_EOL;
mail('[email protected]', 'subject', '<h1>message</h1>', $headers);
?>
Doesn't deliver any messages at all.
Are there any reasons why this might be occurring?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以保证您的代码按原样正常工作,因为我已经测试了您提供的实际代码并将电子邮件发送到我指定的电子邮件地址 - 我在收件箱中看到它带有一个大的
消息
与。我在能够发送电子邮件的服务器中对其进行了测试。您的问题可能是您的服务器不允许您这样做,或者如果它是本地主机,您可能需要使用 SMTP 服务器对其进行设置 - 如果确实正在发送,值得尝试检查您的垃圾邮件文件夹 ;p
I can guarantee that your code works fine
as-is
as I've tested the actual code you provided and got the email sent to my specified email address - I see it in my inbox with a bigmessage
with<h1>
. I tested it in a server that's capable of sending an email. Your issue may be your server not letting you or if it's a localhost you may need to set it up with a SMTP server- if it is indeed sending, worth a try to check your spam folder ;p这是来自 http://php.net/manual/en/function.mail.php< /a>
您是否有能够发送电子邮件的本地服务器(或者远程服务器,如果您已将其配置为这样做)?我知道本地主机服务器可能没有能力实际发送电子邮件,只能接受队列。
That was from http://php.net/manual/en/function.mail.php
Do you have a local server (or a remote on if you have configured it to do so) that is capable of sending emails? I know that localhost servers might not have the capability to actually deliver the email, only accepting queues.