Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I have a Ubuntu machine with Sendmail on it.

Whenever I issue a PHP mail() function, the email gets delivered instantly(received in my inbox on other domain), but the PHP process waits-waits very very long for about 1 minute before returns true.

This is very annoying as causes the browser to appear to hang.

What could be wrong?

share|improve this question
up vote 1 down vote accepted

The first thing to check for long delays when doing network requests is dns issues. Try some dns lookups on your machine, for example nslookup On the remote machine, try the same lookup of your local machine. Try doing dns lookups of the ip address and see if something is wrong with reverse lookup.

Does this delay happen if you send a mail directly on the machine, i.e.:

mail -s "test message" </dev/null

I don't know how the php mail() function works. You need to figure out how exactly it is calling sendmail on the machine - is there something about the way it does that which causes the sendmail process to send the maiul but then sit there doing nothing for a long time afterward?

Check /var/log/sendmailand /var/log/messages on your machine to see if there are any interesting sendmail messages in the logs.

share|improve this answer

Is it really sendmail you have installed? I thought Ubuntu installed postfix by default? In any case, sendmail itself is difficult to configure and even harder to debug problems with that. So I'd recommend switching to another MTA. Programs trying to send mail won't notice a difference.

Secondly, PHP's mail() function is notoriously fussy and tries to do some things for you. This is especially so if you don't provide enough header parameters because it leaves some of the guessing up to the MTA. I would suggest you find PHPMailer or similar. This has a much better API which gives you much more control over what is happening, and sets up a lot more sensible defaults than mail() does.

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.