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[12666]: 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 -ffromtest@test.com problem@problememail.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 ' '
).
Best Answer
Typically email delays are DNS problems.
Try running:
If that doesn't seem to be the problem, use
sendmail -bi -v
to get more debugging output.