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

I have a problem when the mail server can't access the shared storage and then the emails start piling up in the mail queue. Now I would like postfix to try and send the emails to the secondary mail server if it can't do the delivery locally. Is it possible?

I don't know if posfix even supports something like this, because if the domain is in my_destinations then the delivery is local and can't be through a remote system.

Would it be easier to create a script that would check if the mail queue is too big and if it is restart postfix with a different config file, for example one that would make it only a backup mx server and relay mail to the other one. I hope I won't be reinventing the wheel.

share|improve this question
    
Why would you want to do that? You'd just be shifting the problem over to another box, which would probably not be able to make the delivery either. If you'd just use the secondary MX for mail queueing, how would it know when to reattempt the delivery? –  Friek Mar 15 '12 at 19:35
    
Well, for example, last week the first mail server lost connectivity to the storage because of a hardware failure and was still receiving emails and placing them into queue and, until I plugged it out from the net and the secondary box started receiving and delivering mails, there were a few hundred emails in the first's server queue. The secondary MX had access to the storage and was working properly. I had to transfer the mail queue from the first server to the second. –  Jure1873 Mar 16 '12 at 14:19

2 Answers 2

up vote 0 down vote accepted

The proper solution to such a quandary is to separate mail reception from delivery to mailboxes.

On a machine that has dependable connectivity to the backend mail stores, implement a mail delivery agent (MDA), which can be fed by a postfix instance, but may be any MDA that speaks SMTP or LMTP.

This MDA needs to be configured to return an SMTP 4xx status code whenever the mailboxes are unavailable, so the sender will retry later.

The frontend (mail reception) side can be any number and type of MXes.

As a temporary solution on your existing platform, you can set the option -o soft_bounce=yes on your delivery agent, but be warned that this will retry ALL rejected messages.

share|improve this answer

solved this with a script that will probably need improving:

PQ=$(postqueue -p | grep "@" | wc -l)
if [ $PQ -gt 50 ]; then
        echo "Too many emails in queue"
        /etc/init.d/postfix stop
        cp /etc/postfix/main.cf.relay /etc/postfix/main.cf
        /etc/init.d/postfix start
        sleep 360
        /etc/init.d/postfix stop
        cp /etc/postfix/main.cf.local /etc/postfix/main.cf
        /etc/init.d/postfix start
fi
share|improve this answer

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.