简体   繁体   English

PHP mail()函数无法发送到hotmail?

[英]PHP mail() function cannot send to hotmail?

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. 我正在尝试使用PHP mail()函数发送邮件,以便成员可以按照链接进行注册。 It works for Gmail, Yahoo!, but not for Hotmail. 它适用于Gmail,Yahoo!,但不适用于Hotmail。 Please help meh!!! 请帮帮我!!!

   <?php
$headers .= 'To: <kenny.XXX@hotmail.com>' . "\r\n";
$headers .= 'From: <XXX@srv30.000webhost.com>' . "\r\n";
$headers .= 'Cc: XXX@srv30.000webhost.com' . "\r\n";
$headers .= 'Bcc: XXX@srv30.000webhost.com' . "\r\n";
$text="hello";
$text = str_replace("\n.", "\n..", $text);
mail('Kenny Worden:<kenny.XXX@hotmail.com>','Leos Realm account verification!',$text,$headers);
?>

If this helps anyone: 如果这有助于任何人:

SMTP : localhost(srv30.000webhost.com) SMTP:localhost(srv30.000webhost.com)

SMTP PORT: 25 SMTP端口:25

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. 可能是路由/ DNS问题。

edit: i just tried that script on my server and it works well. 编辑:我刚刚在我的服务器上尝试过该脚本,效果很好。 immediately got email on my hotmail address. 马上收到我的hotmail地址的电子邮件。

You're missing the string "-f <from address>" as the fifth parameter. 您缺少字符串"-f <from address>"作为第五个参数。

The PHP Manual points out that you need to supply this so that the MTA will send the correct "From" address on the envelope. PHP手册指出你需要提供这个,以便MTA将在信封上发送正确的“发件人”地址。 Setting it in the headers isn't enough. 在标题中设置它是不够的。 This sort of inanity is why I dis-recommend mail() and point people towards php-mailer or similar. 这种无聊是为什么我不推荐使用mail()并将人们指向php-mailer或类似的东西。

(The "envelope" refers to the conversation an MTA has with another MTA in order to deliver email.) (“信封”是指MTA与另一个MTA进行的对话,以便发送电子邮件。)

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 代码很好,你做的任何东西都会让它看起来像垃圾邮件会阻止它从hotmail尝试为你的域创建spf记录,甚至签名

check your mail server is not blacklisted, this can cause problems http://www.mxtoolbox.com/ 检查您的邮件服务器是否未列入黑名单,这可能会导致问题http://www.mxtoolbox.com/

As @staticsan recommends php-mailer or also http://swiftmailer.org/ are other options you can use try that might help 正如@staticsan推荐的php-mailer或http://swiftmailer.org/是你可以使用的其他选项尝试可能有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM