On our webserver, the PHP
mail() command consistently hangs on some email addresses but is fine with the majority. It hangs for over 2 mins, by which time the PHP script has lost connection with the DB so returns an error to the browser.
We use sendmail and I can see a delay of 2:36 in the mail log (/var/log/maillog) for the email address that causes the problem:
Dec 9 11:24:00 liveserver sendmail: nB9BLOHa012666: to=***blanked_out***, delay=00:02:36, mailer=esmtp, pri=31326, dsn=4.4.3, stat=queued
It is easy to reproduce the problem. I can put the email I want to test in the following command:
echo "Test message from sendmail." | sendmail -firstname.lastname@example.org email@example.com
Most email address cause the command to return within 1s (including invalid email addresses). But the problematic email address hangs for 2:36.
- Why doesn't sendmail queue the message and return immediately so PHP can continue running?
- Does anyone have any tips for debugging the issue?
- Does anyone have any tips on how to probe the problematic email address to see why it is causing a delay?
Note: We currently have 550 messages queued - but this number is not above normal (
find /var/spool/mqueue -type f -name qf\* -print|wc -l|tr -d ' ').