简体   繁体   English

PHP Mail()函数返回错误500内部服务器

[英]PHP Mail() Function returning error 500 Internal Server

I have no idea why this is happening... I get an error 500 internal server error every time I try to run this PHP code. 我不知道为什么会发生这种情况...每次尝试运行此PHP代码时,我都会收到错误500内部服务器错误。 This is the ONLY line of code (it used to be more; narrowed it down to this for testing). 这是唯一的代码行(它曾经更多;将其缩小到此代码进行测试)。

Error logs have been of no help. 错误日志没有任何帮助。 Unfortunately. 不幸。 I have read the other topics posted about this - none of them helped. 我已经阅读了关于此的其他主题 - 他们都没有帮助。

ONLY code: 仅代码:

 <?php
 mail("myemail@example.com", "Test!", "Hello, there!");
 ?>

You need to look into php error log. 你需要查看php错误日志。 Post your logs here if you cant discern which logs are relevant. 如果您无法辨别哪些日志相关,请在此处发布您的日志。 Most likely smtp settings are be blamed. 很可能是smtp设置受到指责。 mail function opens a socket connection. 邮件功能打开套接字连接。 using smtp settings. 使用smtp设置。

SMTP settings can be managed through ini or by : SMTP设置可以通过ini或通过以下方式管理:

ini_set('SMTP', 'smtphost'); 
ini_set('smtp_port', 25); 

The above settings are just for example, you need to have your own smtp settings. 以上设置仅作为示例,您需要拥有自己的smtp设置。 For example if you have Gmail account, you may use it send mail. 例如,如果您有Gmail帐户,则可以使用它发送邮件。 It depends on your specific situation which smtp server you may want to use. 这取决于您可能想要使用的smtp服务器的具体情况。

Here are Gmail SMTP settings . 以下是Gmail SMTP设置 Also look at the documentation 另请查看文档

I have hosted site on Fasthost .it is a windows server, when I sending the email I also faced to this 500 error.After I contact them and resolved the issue. 我在Fasthost上托管了网站。它是一个Windows服务器,当我发送电子邮件时,我也遇到了这个500错误。我联系他们后解决了这个问题。 we can't send emails by using any arbitrary address as ''From'' address in Fasthosts platform due to security reasons, The “from” address must be a mailbox that exists on the Fasthosts platform. 由于安全原因,我们无法使用任何任意地址作为Fasthosts平台中的“发件人”地址发送电子邮件,“来自”地址必须是Fasthosts平台上存在的邮箱。

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

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