Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a Windows 2008 Server running PHP 5.2.11 on IIS 7.5

When any script on the server calls a mail() function it presents no errors and sends the email nearly instantly. However, the server will "hang" for about 60 to 90 seconds until it starts sending information back to the browser. This delay seems to be longer if mail() has not been called in the preceding 2 minutes.

I viewed this issue in the Chrome developer tools "network" tab and it just says "waiting" for that entire period. Once that delay is over, all of the information is sent correctly to the browser and the page renders normally.

Potentially relevant portions of the phpinfo() output:

Internal Sendmail Support for Windows - enabled
sendmail_from - no value
sendmail_path - no value
smtp_port - 25
mail.force_extra_parameters - no value
share|improve this question

PHP mail() is pretty inefficient to start with, the PHP manual itself says:

It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

Not particularly relevant when the number of messages is 1, but there is another potential gotcha:

The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).

Thus unlike the Unix version it can't fire at a local daemon, it has to wait for the network.

I am not a coder, but this is clearly a coding problem. It's likely that the mail function is expecting a certain response from your MTA and not getting it, 60 seconds sounds like a pretty standard timeout value. Also your frontend UI code should not be waiting on mail(), which is typically a background process. It's not too difficult to do this asynchronously.

In summation, you could probably fix this at the MTA level (maybe by setting up a local one on the IIS server), but it's really a coding problem. Suggest nicely to your developers that they don't use mail() when performance is important, and don't block your frontend code when you're waiting for it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.