I'm trying to improve the mail delivery for an organisation I work with (no spam). We have been using our normal mail service's smtp server as a smarthost for delivery, but recently they have blocked the account because it was sending too much mail.

I have looked into and signed up for a SMTP relay service, but these are quite expensive. The reason I don't want to go with sending mail directly is that it's crucial all mail is delivered, and I don't want to be spending a lot of time checking logs to ensure our mail is getting through to everyone.

So I was wondering - Is it possible to setup postfix so that it will first try to send mail directly, and if this fails, then send the mail out through the smart host? This should allow us to send mail to everyone but without having to pay to send all the mail through the SMTP relay.

1 Answer 1


I think it might work as you desire if you run two parallel instances of postfix on the same machine, with the 'deferred' queue directory of the instance sending normally linked (I think symlink would be fine) to the 'incoming' directory of a 2nd instance configured to route to the smarthost. Instance 1 should try to deliver; if it fails, it will write it out to the deferred queue, which instance 2's qmgr will treat as new mail and route to the smarthost.

(You might need to do some tuning on instance 1 to adjust how it retries things it sees in the shared directory, and there are probably all kinds of locking and race condition issues.)

A better solution would probably be still 2 parallel instances, but no shared directory, and a script which scans instance 1's deferred queue, uses postsuper to put it on hold, copies it to instance 2's incoming queue, and purges it from instance 1. This could be triggered from a cron job every few minutes, or perhaps an inotify hook.

  • 1
    I can't vote you up since I don't have enough rep (on this site) yet, but thanks for this answer- I was hoping for a more stock solution but I guess it's something postfix was not designed to handle. I wonder if there is another MTA that could do this, otherwise the script idea sounds good, I could publish it so other people can improve on it also.
    – Jords
    Sep 26, 2010 at 2:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .