I've seen this behavior twice in the past week or so, where mail takes a very long time to send (60 seconds). In troubleshooting one case, I found that cause is setting a custom 'From' header.

I can work around this using a SMTP connection instead of mail() (which is better all around) - just wondering if anyone could shed some light on why setting the header would cause this delay.

I have some guesses, but nothing I know for sure.

Update: Running in Linux. I have to check on the MX records, I'm pretty sure one is correctly pointing to the server (for the domain, although the address isn't really a valid user/alias), the other it's probably not, since this is one of many servers for that domain/company.

Update (2): Actually, the hosting for the one recently changed, so I'm pretty sure neither case has a MX record pointing to the server sending the email. That's likely the issue - although, I'd love to know why the mail is still sent, but with a delay. Looks like this will be moved to ServerFault and perhaps find an answer there.

Log output (actual domain name redacted):

Oct  3 12:28:18 server sendmail[29795]: p93CSI3t029795: from=tjlytle, size=129, class=0, nrcpts=1, msgid=<201110031228.p93CSI3t029795@server.redacted.com>, relay=tjlytle@localhost
Oct  3 12:29:30 server sm-mta[29796]: p93CSIs6029796: from=<tjlytle@server.redacted.com>, size=355, class=0, nrcpts=1, msgid=<201110031228.p93CSI3t029795@server.redacted.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost.localdomain []
Oct  3 12:29:30 server sendmail[29795]: p93CSI3t029795: to=tjlytle@gmail.com, ctladdr=tjlytle (1001/1001), delay=00:01:12, xdelay=00:01:12, mailer=relay, pri=30129, relay=[] [], dsn=2.0.0, stat=Sent (p93CSIs6029796 Message accepted for delivery)
Oct  3 12:29:30 server sm-mta[30649]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
  • linux or windows? if on Linux are you using the sendmail method? did you look at the logs? – stivlo Sep 30 '11 at 15:36
  • 3
    Is the from: address registered on your server? (MX records set etc.) – Pekka Sep 30 '11 at 15:36
  • @stivlo Linux, yup sendmail, and you're right, that's the first thing I would have told someone else - so I'd better do that. – Tim Lytle Sep 30 '11 at 15:42
  • @Pekka I'm unsure of that, I'll have to poke around and find out, pretty sure one server has the MX record, one likely doesn't. That was my guess as to the problem (some kind of SPAM verification/check). – Tim Lytle Sep 30 '11 at 15:42
  • This probably isn't really a programming question, as I think its far more likely due to your server's MTA configuration. I'm going to vote to send this to Serverfault, because I think they're much more likely to know how to fix this. – derobert Sep 30 '11 at 15:44

Check your DNS servers. If you have a broken or slow entry in /etc/resolv.conf, it can cause all sorts of intermittent issues when sending mail.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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