php 警告:mail() [function.mail]:无法在“localhost”端口 25 连接到邮件服务器,请验证您的“SMTP”和“smtp_port”,Windows XP 的 XAMPP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11812884/
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
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port", XAMPP for WIndows XP
提问by Lazar Edit
I am running a XAMPP server on Windows XP. Allegedly XAMPP automatically prepares a mail server.
我在 Windows XP 上运行 XAMPP 服务器。据称 XAMPP 会自动准备一个邮件服务器。
This is the code I am using:
这是我正在使用的代码:
$cimzett = '[email protected]';
...
mail($cimzett, $targy, $uzenet, 'From:'.$email);
($cimzettmeans "to", $targyis subject, $uzenetis message in Hungarian)
but in the browser appling PHP it sends me this message:
($cimzett意思是“到”,$targy是主题,$uzenet是匈牙利语中的消息)但是在应用 PHP 的浏览器中,它向我发送了这条消息:
I get this error message:
我收到此错误消息:
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\PHP\alien.php on line 50
I tried to use set_ini()function too, but I got the same message.
我也尝试使用set_ini()函数,但我得到了相同的消息。
Maybe the security properties of XAMPP does not allow me send an email to gmail.com?
也许 XAMPP 的安全属性不允许我向 gmail.com 发送电子邮件?
I use PHP Version 5.3.5 and
我使用 PHP 版本 5.3.5 和
SMTP localhost localhost smtp_port 25 25
SMTP 本地主机本地主机 smtp_port 25 25
are the settings reported by phpinfo();
是 phpinfo() 报告的设置;
I suspect the mail server is not working properly. What do you think?
我怀疑邮件服务器工作不正常。你怎么认为?
回答by Marc B
Windows does not by default have an SMTP server installed. XAMPP won't install one for you either. If there IS one installed, then it's not running, because "connection refuse" on port 25 means nothing's there listening for email.
默认情况下,Windows 没有安装 SMTP 服务器。XAMPP 也不会为您安装。如果安装了一个,那么它就不会运行,因为端口 25 上的“连接拒绝”意味着没有任何东西在侦听电子邮件。
XAMPP will also not disable connections to external mail servers. However, Windows firewalls and/or some ISPs will (my isp does not allow external smtp connections as an anti-spam measure).
XAMPP 也不会禁用与外部邮件服务器的连接。但是,Windows 防火墙和/或某些 ISP 会(我的 isp 不允许外部 smtp 连接作为反垃圾邮件措施)。
回答by zb'
May be you should setup mail submitting as external account, your gmail one for example. more info here: Authentication php mail
可能是您应该将邮件提交设置为外部帐户,例如您的 gmail 帐户。这里有更多信息: 身份验证 php 邮件
回答by WatsMyName
Well if you want to do it anyway in your local machine, try installing IIS and configure the SMTP server from there. Remember this process is only for SMTP, you dont have to change existing installation of Apache and PHP. For more details,here is the link http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
好吧,如果您无论如何都想在本地计算机上执行此操作,请尝试安装 IIS 并从那里配置 SMTP 服务器。请记住,此过程仅适用于 SMTP,您不必更改 Apache 和 PHP 的现有安装。有关更多详细信息,请访问 http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
After following steps, the mail will be saved as a file in wwwroot directory. You may need to make further research on this, but you can take this solution as a starting point.
完成以下步骤后,邮件将作为文件保存在 wwwroot 目录中。您可能需要对此进行进一步研究,但您可以将此解决方案作为起点。
hope this helps
希望这可以帮助
回答by Azan Momin
You will need an additional SMTP Server Application because Xampp doesn't support it. Download "Post Cast Server" version > 2. Goto tools -> Settings -> System -> SMTP server and set Host name as localhost server port as 25. And run the application minimized. It will definitely work because it has worked out for me when I was facing the same problem.
您将需要一个额外的 SMTP 服务器应用程序,因为 Xampp 不支持它。下载“Post Cast Server”版本 > 2. 转到工具 -> 设置 -> 系统 -> SMTP 服务器并将主机名设置为 localhost 服务器端口为 25。并运行最小化的应用程序。它肯定会起作用,因为当我面临同样的问题时,它对我有用。

