【发布时间】:2012-12-15 14:12:32
【问题描述】:
我在 stackoverflow 和 google 上搜索了如何设置 xampp、mercury 和 php 代码以使用 window server 2008 r2 发送邮件。
通过教程发现我可以使用Mail::factory 和smtp.gmail.com 发送邮件,也可以使用Mercury 发送邮件(File -> 发送邮件消息),my_email_address@my_domain_name.com 在 Mercury 中注册。所以我尝试使用php 代码发送邮件。但在我的情况下它仍然不起作用。
这是我的配置:
C:/xampp/apache/php.ini
sendmail_path = "\xampp\sendmail\sendmail.exe -t -i"
sendmail.ini
smtp_server=my_domain_name.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=my_email_address@my_domain_name.com
auth_password=my_password
force_sender=my_email_address@my_domain_name.com
hostname=my_domain_name.com
代码 php
$to = $email;
$subject = "Hello";
$message = "How are you ?";
$from = "my_email_address@my_domain_name.com";
$headers = "From:" . $from;
$result = mail($to,$subject,$message,$headers);
if($result){
echo "Mail Sent." . $result;
}
else{
echo "Failure." . $result;
}
我签入C:\xampp\sendmail\debug.log 并收到错误
--- MESSAGE END ---
12/12/31 06:46:04 ** Connecting to my_domain_name.com:25
12/12/31 06:46:06 ** Disconnected.
12/12/31 06:46:06 ** Disconnected.
12/12/31 06:46:06 ** Disconnected.
12/12/31 06:46:06 ** Socket Error # 10061<EOL>Connection refused.
我哪里错了?你能帮帮我吗?
【问题讨论】:
-
您的
debug.logSocket Error [..] Connection refused表明,没有 SMTP 服务器实际上在回复my_domain_name.com:25确保有一个 smtp 服务器启动并运行,并且端口 25 没有被防火墙阻止。 -
@MichelFeldheim 谢谢你的回答,我检查了我的窗口防火墙,SMTP 端口 25 在入站规则中是允许的,但仍然无法正常工作。我如何知道 smtp 服务器已启动并正在运行?
标签: php xampp sendmail.exe