THE SPEW - Land where drunk cows swim and home to my daily hand...
streaming media & music | Home | Archives | Albums | Pics

Postfix backup mail server using the defer and hold queues - Here are the parameters I used for this test:

28 March, 2008 01:51

First thing is first.  If I decide to move out of state, and my home mail server is unavailable, I want to make sure mail is held for at least 45 days, even though the primary mail exchange server might have a week or two of queue lifetime.

The backup MX priority 20 will not accept any incoming mail other than the domains or addresses listed as I will describe bellow, it is not a matter of resource load, it is just a pure backup mall server. 

For mx1.mailhost [DNS MX Priority 10, the first], I have the ONE variables defined to use, for relay to the backup after its own queue experiation: 

SMTP_FALLBACK_RELAY = MY.MX2.IP.ADDR


I couldn't imagine not having the need to flush the queue after 45 days, so here is the variable I defined:

MAX_QUEUE_LIFETIME = 45d

Next you want to list the domains, or fully qualified e-mail addresses that you want backed up.  You can store this in text, hash, mysql, sqlite, etc...

permit_mx_backup = host1.com host2.com user@host3.com user@host4.com

When you initially receive mail for the permit_mx_backup list, it is put immediately into a spool, that of which you can define the type of with FALLBACK_TRANSPORT.  It is not touched: no attempt to deliver, scan the messages - it just plain forgets about the incoming mail that got stored.  This is how I did this:

MINIMUL_BACKOFF_TIME = 43200

The above example is in seconds which equals 8 hours.  I can get an easily repairable downed server up in that amount of time.  The suffix can be appended with h (hour) or d (day).

After the initial  back-off time, the next attempt will not be made for another 2 hours as defined in this following configuration variable:

QUEUE_RUN_DELAY = 7200

Consecutive attempts will be made every two hours, after the minimal backup time, until the max queue lifetime of 45 days expires, in which case you could use a non normalized form of archiving your mail to an external source, or a 3rd backup MX priority 30 for a third archive.

After 8, 10, or 45 days, you may then deliver the mail back to your primary mail exchange server by flushing the hold queue into the active queue, with instructions in "man postsuper"


Since we re not accepting incoming public mail on mx2, I use this variable to defer the e-mail at each connection attempt until mx1 can be brought back on-line:

SMTPD_RECIPIENT_RESTRICTIONS = defer

This will defer the message from all - FROM: email@ANY, and notify that the sender that the e-mail is temporarily unable to be received. It will then try other MX priority servers in your DNS entries.

If the address or domain is in the permit_mx_backup list, than this list is the only mail that will be accepted and backed-up.  Make sure you have your trusted networks in which this is allowed defined for this. I use the following variable (incoming mail):

SMTPD_SENDER_RESTRICTIONS = permit_mx_backup, defer 

Make some modifications to the above, and see what works best for you.  I have only tested, needed, and used this for two days, so numerous modifications may be needed, not to mention modifications in conjunction with other SMTP provisionings you may have.

[Software] [Projects]
[Comments(0)] [Trackbacks(0)] [Permalink]

Add comment

Add comment
 authimage
Your E-Mail Address will NOT be Shared

Main Entry: spew
Function: verb
Etymology: Middle English, from Old English spIwan; akin to Old High German spIwan to spit, Latin spuere, Greek ptyein intransitive verb
1 : VOMIT
2 : to come forth in a flood or gush
3 : to ooze out as if under pressure : EXUDE transitive verb
1 : VOMIT
2 : to send or cast forth with vigor or violence or in great quantity -- often used with out - spew-er noun
--
Merriam-Webster

Land where drunk cows swim and home to my daily hand