PHP mail() 函数无法发送到hotmail?
好吧,我在互联网上搜索了答案 - 遗憾的是没有结果。我正在尝试使用 PHP mail() 函数发送邮件,以便会员可以按照链接进行注册。它适用于 Gmail、Yahoo!,但不适用于 Hotmail。请帮帮我吧!!!
<?php
$headers .= 'To: <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";
$text="hello";
$text = str_replace("\n.", "\n..", $text);
mail('Kenny Worden:<[email protected]>','Leos Realm account verification!',$text,$headers);
?>
如果这对任何人有帮助:
SMTP : localhost(srv30.000webhost.com)
SMTP PORT: 25
Okay, I have searched on the internet for answers- sadly to no avail. I'm trying to send mail using the PHP mail() function so members can follow the link to register. It works for Gmail, Yahoo!, but not for Hotmail. Please help meh!!!
<?php
$headers .= 'To: <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";
$text="hello";
$text = str_replace("\n.", "\n..", $text);
mail('Kenny Worden:<[email protected]>','Leos Realm account verification!',$text,$headers);
?>
If this helps anyone:
SMTP : localhost(srv30.000webhost.com)
SMTP PORT: 25
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的代码看起来不错。我的猜测是您的服务器端出现问题,请检查邮件传送日志或让您的服务器管理员为您查看它们。可能是路由/dns 问题。
编辑:
我刚刚在我的服务器上尝试了该脚本,效果很好。我的 hotmail 地址立即收到电子邮件。
Your code seems to be good. My guess is that there is something wrong at your servers end, check mail delivery logs or have your server admin look at them for you. Could be a routing/dns issue.
edit:
i just tried that script on my server and it works well. immediately got email on my hotmail address.
您缺少字符串
"-f"
作为第五个参数。PHP 手册 指出您需要提供此信息,以便 MTA将发送信封上正确的“发件人”地址。将其设置在标题中是不够的。这种愚蠢就是为什么我不推荐
mail()
并引导人们使用php-mailer
或类似的东西。(“信封”是指 MTA 与另一个 MTA 之间为了传递电子邮件而进行的对话。)
You're missing the string
"-f <from address>"
as the fifth parameter.The PHP Manual points out that you need to supply this so that the MTA will send the correct "From" address on the envelope. Setting it in the headers isn't enough. This sort of inanity is why I dis-recommend
mail()
and point people towardsphp-mailer
or similar.(The "envelope" refers to the conversation an MTA has with another MTA in order to deliver email.)
代码喜欢就好,
您所做的任何使其看起来像垃圾邮件的操作都会阻止其接收 Hotmail
尝试为您的域创建 spf 记录,甚至签名
检查您的邮件服务器是否已列入黑名单,这可能会导致问题
http://www.mxtoolbox.com/
正如 @staticsan 推荐的 php-mailer 或 http://swiftmailer.org/ 是您可以尝试使用的其他选项,可能会有所帮助
code likes fine,
anything you do that makes it look like spam will block it from hotmail
try creating spf records for your domain, and even signatures
check your mail server is not blacklisted, this can cause problems
http://www.mxtoolbox.com/
As @staticsan recommends php-mailer or also http://swiftmailer.org/ are other options you can use try that might help