Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here's the situation: I've got a Redhat Linux server with PHP 5.2 and standard sendmail that we're using to send email to a list of 10,000 email addresses. We have a fairly simple script that uses PHPMailer and connects over SMTP to the listening sendmail daemon.

Whenever this script runs, it'll eventually get to the point where it will just start running dirt slow - it'll start off fast, but then slow down to only sending 1 email every few minutes. When I restart the script, it runs fast again for a bit.

Over on the sendmail server, I've added a few settings in the script to attempt to fix the throttling issue:

define(`confMAX_QUEUE_RUN_SIZE',`0')dnl
define(`confBAD_RCPT_THROTTLE', `0')dnl
define(`confCONNECTION_RATE_THROTTLE', `0')dnl

So far, I'm not sure the best way to fix the problem - or to even troubleshoot it. The /var/log/maillog file doesn't really have any useful information in it.

We've got this sendmail instance behind a firewall, so we don't need to worry about security... just open it up and let the mail flow!

share|improve this question
add comment

2 Answers

You shouldn't be connecting to the remote SMTP by script, but deliver to the localhost using sendmail (or better, postfix). Sendmail should take care of delivering the messages. If you need to make sure all messages go out through a specific gateway machine, configure sendmail with the correct smarthost.

The reason you want to do this is that sending mail is much more complex then you might initially think, and sendmail (or better, postfix) is built to handle all of the gory details like queue management.

As for what's happening on the mail server itself, have you checked the load and other factors on that server? It might be overloaded after you've sent so many messages to it, and is legitimately slow because of it. Check things like 'top', 'netstat -n', etc...

share|improve this answer
    
When I use sendmail directly, the email messages that go out have a "from 127.0.0.1" in the headers, which is causing issues with spam filters. Is there a way around that? –  The How-To Geek Feb 22 '10 at 21:02
    
127.0.0.1 frequently shows up in email headers, as it's often used to resubmit messages to "myself" to perform operations like spam filtering, antivirus scanning, etc... I think if a spam filter is complaining about this, the filter should probably be adjusted. –  brianmathis Feb 23 '10 at 23:55
add comment

You may want to try increasing the log verbosity on sendmail. That may give you some more clues.

You may need to try to determine if the latency is coming from the PHP side or from the sendmail side.

When it get's slow, run a netstat and see what ports are open.

Double check DNS. Make sure your server can quickly resolve domain names. Often I run a caching DNS server locally when sending large volumes of email.

I've not used PHPMailer in this fashion but I've been able to just call /usr/sbin/sendmail via a php script as see 600+ messages/minute on modest hardware.

share|improve this answer
    
Forgot to add, make sure you are using multiple queues in sendmail, check your timeouts and other SMTP side tuning. The server side tuning on sendmail can make a huge difference in your send rate, especially if you are sending a lot of emails to the same domain. –  jeffatrackaid Feb 22 '10 at 20:21
    
Would that make the script hang when trying to connect to SMTP? –  The How-To Geek Feb 22 '10 at 20:25
add comment

Your Answer

 
discard

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.