mail()超时问题 [英] mail() timeout issue

查看:165
本文介绍了mail()超时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过浏览器执行我的电子邮件脚本时,会返回超时致命错误(除非我大大增加执行时间,否则运行正常,而不是我要查找的解决方案)。 发送电子邮件为,但始终(5分钟平均)到达(在我的收件箱)!

(考虑到通过命令行,它完美运行,我认为SMTP在php.ini当然配置良好。)

When I execute my email script via browser a timeout fatal error is returned (unless I drastically increase the execution time, then it will run ok, not the solution I'm looking for). The email is sent tho, but it takes forever (5 min. average) to arrive (at my inbox)!
(Considering that via command line it works perfectly I think that SMTP at php.ini is certainly well configured.)

所以这是由浏览器请求执行的代码:

So this is the code executed by browser request:

<?php
mail('amatos@example.com', 'test subject', 'test body', 'From: Andre Matos <amatos@example.com>');
?>

当我运行相同(真的是一样吗?我开始怀疑自己)代码通过命令行:

and when I run this same (is it really the same? I'm starting to doubt myself) code via command line:

php -r "mail('amatos@example.com', 'test subject', 'test body', 'From: Andre Matos <amatos@example.com>');"

它工作完美!脚本运行,它停止,电子邮件立即到达(2/3秒)。

it works perfectly! The script runs, it stop and the email arrives instantly (2/3 seconds).

那么,什么可以导致这种差异以及如何解决?任何想法?

提前感谢

So, what can cause this difference and how to fix it? Any ideas?
Thanks in advance.

一些额外的信息:

- 机器是windows

- 服务器是本地主机

- php.ini对于浏览器和cli实例都是一样的

[edit] some extra info:
- the machine is windows
- the server is localhost
- php.ini is the same for both the browser and the cli instance

[edit2]

感谢大家试图猜测是哪个问题。我把这个问题转移到有人问题之前,知道一些具体的东西。没有什么具体的出现,没有一个建议真的有效,我决定接受一个允许我得到更多的结论关于这个问题... +1对于所有你的有用的知识/想法(/猜测):-)

[edit2]
Thank you all for trying to guess which was the problem. I placed the question hopping that someone had the problem before and knew of something specific. Given nothing specific showed up and none of the suggestions really worked, I've decided to accept the one that allowed me to reach more conclusions about the problem... +1 For all your helpful knowledge/thoughts (/guesses) :-)

推荐答案

我已经假设了一些couses,但我习惯了linux和windows我可以olny猜测:

I've hypothesised some couses, but I used to linux and on windows I can olny guess:


  1. php_cli和mod_php是2个不同的二进制文件,mod_php可以稍微损坏

  2. php_cli和mod_php使用2个不同的用户, apache用户的网络配置文件可能是问题(dns,firewall,proxy ...)

  3. 您的php脚本位于有问题的位置或包含一些有问题的字符,但是您的cli脚本是通过param,尝试执行相同的脚本:php -fz:\path\to\php\mail.php

这篇关于mail()超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆