Sendmail Wamp PHP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21337859/
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
Sendmail Wamp Php
提问by Rumpelstinsk
I have spent all the morning searching this on internet trying to find a solution about this. I have installed wamp server on Windows 8.1 and i'm trying to send some mails with sendmail (http://glob.com.au/sendmail/) and my gmail account
我花了一上午的时间在互联网上搜索这个,试图找到一个解决方案。我已经在 Windows 8.1 上安装了 wamp 服务器,我正在尝试使用 sendmail ( http://glob.com.au/sendmail/) 和我的 gmail 帐户发送一些邮件
When i configure sendmail to use port no 465 I always get this error: Socket Error # 10060Connection timed out
当我将 sendmail 配置为使用端口号 465 时,我总是收到此错误:Socket Error # 10060Connection timed out
If i try to use port no 587 i get this line on error log: Connection Closed Gracefully. But no email is sent.
如果我尝试使用端口号 587,我会在错误日志中看到这一行:Connection Closed Gracefully。但是没有发送电子邮件。
This is my sendmail.ini file
这是我的 sendmail.ini 文件
[sendmail]
smtp_server=smtp.gmail.com
;I tried both: 587, 465
smtp_port=587
; I tried: "blank, auto ssl, tls, none"
smtp_ssl=
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=mypass
hostname=localhost
And this is php.ini file
这是 php.ini 文件
[mail function]
smtp_port = 465
sendmail_path="C:\wamp\sendmail\sendmail.exe -t"
mail.add_x_header = On
ssl_module is active on apache, and php uses php_open_ssl and php_socket extension.
ssl_module 在 apache 上是活动的,php 使用 php_open_ssl 和 php_socket 扩展。
Also i tried to use stunnel whitout any success
我也尝试使用 stunnel whitout 任何成功
EDIT 27/01/2014
编辑 27/01/2014
I set smtp_port = 465 and smtp_ssl=ssl on sendmail.ini. Also, I set that sendmail.exe has to run as a Windows XP SP3 programs. After doing that, when I run sendmail.exe on windows console, it sends the email correctly. However, when wamp tries to send mails i get this error on sendmail's error logs.: Socket Error # 10060Connection timed out.
我在 sendmail.ini 上设置了 smtp_port = 465 和 smtp_ssl=ssl。此外,我设置 sendmail.exe 必须作为 Windows XP SP3 程序运行。这样做之后,当我在 Windows 控制台上运行 sendmail.exe 时,它会正确发送电子邮件。但是,当 wamp 尝试发送邮件时,我在 sendmail 的错误日志中收到此错误:套接字错误 # 10060Connection 超时。
This is the code I'm using to test sendmail:
这是我用来测试 sendmail 的代码:
<?php
$email = "[email protected]";
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,How are you?";
$headers = 'From: ' .$email . "\r\n".'Reply-To: ' . $email. "\r\n".'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $body, $headers)) echo("<p>Email successfully sent</p>");
else echo("<p>Email delivery failed</p>");
?>
回答by Rumpelstinsk
Finally I found the answer.
最后我找到了答案。
The problem is that sendmail has to be run as an administrator. This is the solution to help any one on my situation.
问题是 sendmail 必须以管理员身份运行。这是帮助任何人解决我的情况的解决方案。
- Right click on sendmail.exe
- Properties
- Compatibility
- Change the configuration for all users
- Execute as Windows XP SP 3
- Execute as adminitrator
- 右键单击 sendmail.exe
- 特性
- 兼容性
- 更改所有用户的配置
- 作为 Windows XP SP 3 执行
- 以管理员身份执行
And save :D
并保存:D
2 days lost in this nonsense :(
在这个废话中迷失了 2 天 :(
回答by Yahya Uddin
As an extension to the accepted answer:
作为已接受答案的扩展:
If you are running the send mail function in PHP, a dialog may come up to ask you to run the 'send mail' app as admin. Upon cliking 'Yes' it will show a command prompt dialog and nothing will happen and you page will hang until the command prompt is closed. The mail function will even return "True", but in reality no message was sent.
如果您在 PHP 中运行发送邮件功能,可能会出现一个对话框,要求您以管理员身份运行“发送邮件”应用程序。单击“是”后,它将显示一个命令提示符对话框,并且不会发生任何事情,您的页面将挂起,直到命令提示符关闭。邮件函数甚至会返回“True”,但实际上并没有发送任何消息。
To solve this issue, do the instructions same as the accepted answer and ALSO run the server (or IDE) as admin, by either:
要解决此问题,请执行与接受的答案相同的说明,并以管理员身份运行服务器(或 IDE),方法如下:
1) Right clicking the program (e.g. server, ide, command prompt) and clicking "Run as Administer"
1) 右键单击程序(例如服务器、IDE、命令提示符)并单击“以管理员身份运行”
2) OR Right click program> properties> compatiblity> Tick execute as admin
2)或右键单击程序>属性>兼容性>勾选以管理员身份执行
For instance if your using the PHP in built server, run the command prompt as admin and start the server as normal using
例如,如果您在内置服务器中使用 PHP,请以管理员身份运行命令提示符并使用以下命令正常启动服务器
C:\wamp\bin\php\php5.5.12\php.exe -S localhost:80 -t C:\Users\path\to\rootFolder
Of course change the file paths to suit your needs.
当然,更改文件路径以满足您的需要。
Hope this helps someone!!! Spent ages on this!
希望这对某人有帮助!!!在这上面花了很多时间!
回答by Juan Carlos Conde
The problem is that sendmail has to be run as an administrator. This is the solution to help any one on my situation.
问题是 sendmail 必须以管理员身份运行。这是帮助任何人解决我的情况的解决方案。
- Right click on sendmail.exe
- Properties
- Compatibility
- Change the configuration for all users
- Execute as Windows XP SP 3
- Execute as adminitrator
- if you using gmail you need create new password "Your application-specific passwords"
- 右键单击 sendmail.exe
- 特性
- 兼容性
- 更改所有用户的配置
- 作为 Windows XP SP 3 执行
- 以管理员身份执行
- 如果您使用 gmail,则需要创建新密码“您的应用程序专用密码”
回答by Matt
On Windows 10, I found the only method that worked was to run the Compatibility Troubleshooter.
在 Windows 10 上,我发现唯一有效的方法是运行兼容性疑难解答。
- Right click on sendmail.exe
- Click "Properties"
- Select the Compatibility tab.
- Click "Run Compatibility Troubleshooter".
- Let windows fix it automatically.
- 右键单击 sendmail.exe
- 点击“属性”
- 选择兼容性选项卡。
- 单击“运行兼容性疑难解答”。
- 让 Windows 自动修复它。


