Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php mail() hangs on bad dns

Status
Not open for further replies.

Kiehlster

MIS
Aug 14, 2000
147
US
We have a mail queue application we wrote for our clients to send out their newsletters and whatnot. Everything has been going fine, but now we've discovered a problem with php's mail() function. I'm sure this has something to do with sendmail not giving up on bad domains, but anyway, here's the deal.

We have one email that I discovered after digging real deep which goes something like "info@somesite.com.au". I don't think we've found this problem before, but between yesterday and today, this .com.au address's name server is not responding. You'd think sendmail would give up after a few seconds but instead it hangs forever and ever (or at least over 13 hours which is when I killed it). This in turn hangs the mail function and hangs the php application and then crontab comes around again and tries to do the same thing again and we end up with about 30 people who received the email 20 times.

Is there some way to tell sendmail to give up on dns after a few seconds rather than a few years? Thanks!

Steve Kiehl
Web Page Designer - Nanovox Productions
Unwords Dictionary of Made-Up Words
 
If the path to the sendmail app is correctly set, mail() will send email using it.

sendmail, as I understand it, only injects emails into the outgoing queue. It should not hang under any circumstances.


On what platform are you running PHP?
What are your php.ini email settings?
If you attempt to send an email to the offending email address through sendmail from the command-line, does the sendmail app hang?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I'm running php 5.0.4 on FreeBSD 5.4, and sendmail 8.13.3. The mail() function does work. Over 2600 other emails went out just fine. Only two emails caused a hang in the long-run. From all my investigation, I could only assume it was because sendmail does a dns lookup before queuing an email, and doing a dns lookup on that address resulted in the program freezing until I killed the associated sendmail process. This also resulted in our mysql server getting clogged because there were too many connections to the server from each instance of the script that was hung up waiting for sendmail to finish (which didn't happen until I killed sendmail).

In the end I've rewritten the script to do emails more individually than before (one at a time rather than chunks), and so this will allow the script to run multiple instances without overlapping each other so much. However, it still bothers me that the mail function can hang.

To see for yourself, try sending an email to junk@austarmetro.com.au. Austarmetro is the company that owns the name server for the email address in question. I get a timeout when trying to go to austarmetro.com.au's website, and I get timeouts when trying to look up dns on their name servers. It would seem that there's something wrong with this isp that is causing no response to dns. I think sendmail is trying over and over to get a successful response for the dns, but is in turn hanging because it keeps trying too much.

Steve Kiehl
Web Page Designer - Nanovox Productions
Unwords Dictionary of Made-Up Words
 
I don't know.

I'm using postfix. When I try to send mail to that address, the message is posted to the queue immediately. Only after the mail is in the queue does postfix show problems submitting the data. Sendmail may behave differently.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top