PHP 的 mail() 函数在 GoDaddy 专用服务器上不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10095456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP's mail() function doesn't work on GoDaddy dedicated server
提问by jball037
I have a website that is hosted by GoDaddy on a virtual dedicated platform, and I haven't been able to get the mail()function to work properly in my PHP script. I'm trying to send emails with validation codes to people when they first sign up to my website, and the mail()function works great for Gmail address, but not others like AOL or even GoDaddy's email service!
我有一个由 GoDaddy 在虚拟专用平台上托管的网站,但我无法mail()在我的 PHP 脚本中使该功能正常工作。当人们第一次注册我的网站时,我试图向他们发送带有验证码的电子邮件,该mail()功能非常适用于 Gmail 地址,但不适用于其他人,例如 AOL 甚至 GoDaddy 的电子邮件服务!
I tried talking with multiple GoDaddy support reps but they weren't really helpful on the issue. I've looked around online and it seems like this is a very common problem with people who are hosting their websites on GoDaddy. I'm not getting bounce back emails when I the emails fail so it's hard to know what's going on.
我尝试与多个 GoDaddy 支持代表交谈,但他们对这个问题并没有真正的帮助。我在网上环顾四周,对于在 GoDaddy 上托管网站的人来说,这似乎是一个非常普遍的问题。当我的电子邮件失败时,我不会收到退回的电子邮件,因此很难知道发生了什么。
Here is my PHP code:
这是我的PHP代码:
$sendtoemail = '[email protected]';
$emailsubject = "Please validate your email";
$emailbody = "Validation info, blah blah.";
$emailheader = 'From: [email protected]' . "\r\n" .
'X-Mailer: PHP' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'[email protected]';
mail($sendtoemail, $emailsubject, $emailbody, $emailheader);
I've gotten a few errors when I checked /usr/local/psa/var/log/maillog(accessed through PuTTY SSH) that all ended in: deferral: ./Maildir:_No_such_file_or_directory/
当我检查/usr/local/psa/var/log/maillog(通过 PuTTY SSH 访问)时,我遇到了一些错误,这些错误都以:deferral: ./Maildir:_No_such_file_or_directory/
I have also activated reverse DNS on my hosting account and created an SPF DNS record that sends email through "GoDaddy only" and checked the "Include PTR" box for DNS lookup. This was under the "TXT (text)" section of the "Zone File Editor" on GoDaddy's DNS manager. (Hopefully that makes more sense to you than it does to me).
我还在我的托管帐户上激活了反向 DNS,并创建了一个 SPF DNS 记录,该记录通过“GoDaddy only”发送电子邮件,并选中“Include PTR”框进行 DNS 查找。这是在 GoDaddy 的 DNS 管理器上“区域文件编辑器”的“TXT(文本)”部分下。(希望这对你来说比对我更有意义)。
回答by Jared Goodner
This is an old thread, but thought I'd add my experiences in case they helped someone else.
这是一个旧线程,但我想我会添加我的经验,以防他们帮助其他人。
I had very similar problems with mail(), and I called up GoDaddy's tech services. I was on the phone for 2 hours, and after 30 or so test calls to mail() (they even uploaded their own 'testmail' script), I hadn't received one email successfully (though mail() returned a value of 1, i.e. successful). The end result was that he told me that the email server relays were "queued up". After two hours, one tech support guy and his "sys admin"...still the same problem.
我在使用 mail() 时遇到了非常相似的问题,于是我拨打了 GoDaddy 的技术服务电话。我在电话上打了 2 个小时,在对 mail() 进行了 30 次左右的测试调用后(他们甚至上传了自己的“testmail”脚本),我还没有成功收到一封电子邮件(尽管 mail() 返回了 1 的值,即成功)。最终结果是他告诉我电子邮件服务器中继已“排队”。两个小时后,一名技术支持人员和他的“系统管理员”......仍然是同样的问题。
The solution was to use php library swiftmailerinstead of the plain old mail() function. Emails sent immediately using swiftmailer. Hope this helps someone else!
解决方案是使用 php 库swiftmailer而不是普通的旧 mail() 函数。使用 swiftmailer 立即发送电子邮件。希望这对其他人有帮助!
Needless to say, I've changed hosting providers!
不用说,我已经更换了托管服务提供商!
回答by HarryBeasant
I am not sure if GoDaddy support PHP Mail, this is usually a big problem for web hosting companies because its used in scripts to send spam.
我不确定 GoDaddy 是否支持 PHP Mail,这对于网络托管公司来说通常是一个大问题,因为它用于发送垃圾邮件的脚本。
The best thing to do is check what PEAR extensions GoDaddy have on there hosting, if they have PEAR mail, you can use that. If not, then you should try using authenticated mail sending.
最好的办法是检查 GoDaddy 在托管上有哪些 PEAR 扩展,如果他们有 PEAR 邮件,您可以使用它。如果没有,那么您应该尝试使用经过身份验证的邮件发送。
I can give you an example of PEAR and Authenticated mail if you need.
如果你需要,我可以给你一个 PEAR 和 Authenticated 邮件的例子。
回答by m-t
your need to use default variables of PHP mail() for GoDadday, i don't know but when i used your snippet it won't work for me too, but by using standard variables, i got the mail; and yes don't use variable for dedicated email address, put in mail() function as i did, 
您需要为 GoDadday 使用 PHP mail() 的默认变量,我不知道,但是当我使用您的代码段时,它也不适用于我,但是通过使用标准变量,我收到了邮件;是的,不要将变量用于专用电子邮件地址,像我一样放入 mail() 函数,
try hope will work for you too;
尝试希望也会对你有用;
$subject = "Please validate your email";
$message = "Validation info, blah blah. 2nd msg";
$Header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Header .= 'From: Lux <[email protected] >' . "\r\n";
if(mail('[email protected]', $subject, $message, $Header))
echo "email sent";
else
echo "email sending fail";
回答by Elmo
So I did some work using php's mail function on godaddy deluxe hosting. It would send to my gmail account but an actual email account using a domain that was on godaddy the mail never made it. I have to believe that there are some sort of method to the madnesss. My suggestion is try a different email if you aren't getting the mails from mail(). I know this puts a wrench in to your perfect setup of where you want the emails to go but at least you get the emails. Perhaps you could use a forwarding trick to get the mail in to your inbox of choice once you actually get the mail.
所以我在godaddy豪华主机上使用php的邮件功能做了一些工作。它会发送到我的 gmail 帐户,但使用 godaddy 上的域的实际电子邮件帐户从未发送过邮件。我必须相信有某种方法可以解决这些疯狂问题。如果您没有从 mail() 收到邮件,我的建议是尝试使用不同的电子邮件。我知道这会影响您完美设置电子邮件的去向,但至少您可以收到电子邮件。也许您可以使用转发技巧在您实际收到邮件后将邮件发送到您选择的收件箱。

