I have a webservers that send out emails to a sendmail relay server as a batch job. The emails need to be accepted by the relay sendmail server as fast as possible, however, they do not need to go out (be relayed) very quickly.

I am seeing a couple timeouts once and a while from the webserver trying to connect to the relay server. The load currently is about 30 emails a second for a couple minutes.

There are quite a few tuning options for sendmail in the sendmail tuning guide.

What I am focusing on now is the Delivery Mode:

Delivery Mode

There are a number of delivery modes that sendmail can operate in, set by the DeliveryMode ( d) configuration option. These modes specify how quickly mail will be delivered. Legal modes are:

i deliver interactively (synchronously) b deliver in background (asynchronously) q queue only (don't deliver) d defer delivery attempts (don't deliver) There are tradeoffs. Mode i gives the sender the quickest feedback, but may slow down some mailers and is hardly ever necessary. Mode b delivers promptly but can cause large numbers of processes if you have a mailer that takes a long time to deliver a message. Mode q minimizes the load on your machine, but means that delivery may be delayed for up to the queue interval. Mode d is identical to mode q except that it also prevents lookups in maps including the -D flag from working during the initial queue phase; it is intended for ``dial on demand'' sites where DNS lookups might cost real money. Some simple error messages (e.g., host unknown during the SMTP protocol) will be delayed using this mode. Mode b is the usual default. If you run in mode q (queue only), d (defer), or b (deliver in background) sendmail will not expand aliases and follow .forward files upon initial receipt of the mail. This speeds up the response to RCPT commands. Mode i should not be used by the SMTP server.

I currently have the CentOS default modes:




  • Is sendmail.cf/mc for outgoing email from relay (to the intertubes) and sumbit.cf/mc for incoming eamil (from my webservers).
  • Would it make sense to change the outgoing delivery mode to queue? If I did, what would the outbound email flow behave like?
  • If this is the right thing to do, can anyone show me example mc configurations for this change? If it isn't, what recommendations are there for these constraints?


** I'm by no means a sendmail expert **

In your use case, the need for sendmail to accept / queue up the messages asap is key(batch processing?). If you haven't, take a look at sendmail options: QueueLA and RefuseLA - Queue Load Average and Refuse Load Average. If you are really bombarding sendmail your load averages will go through the roof quickly and you'll hit RefuseLA which might be part of your timeout issue. You may want to increase RefuseLA (if you haven't already).

To keep sendmail from doing too much at once (receiving and transmitting) lower your QueueLA. A lower value of QueueLA will put sendmail into queue only mode so sendmail will focus on queuing work and save the transmit / sending work for later. A low QueueLA and high RefuseLA will result in the system queueing up large amounts of mail(disk space) then begin sending it out after the load falls below QueueLA.

For normal sendmail configs it is worth noting that QueueLA should not be much lower than RefuseLA, and possibly it should be very slightly higher.

Delivery mode 'q' is an extreme version of a low QueueLA setting, where you'd have to somehow initiate a delivery command to begin outbound message transfer.

Resource: http://www.brandonhutchinson.com/QueueLA_and_RefuseLA.html

| 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.