Is there a way to pause mail delivery in Postfix (accumulate in queue)?

When using combination of Postfix/Dovecot, is there a way to tell smtp server (Postfix) not to store mails on disk but hold/add them to queue until "maintenance finished"?

Useful for disk upgrades, volume extensions, chkdisk etc.


Solution 1:

I don't believe so; the incoming queue is on disk. Perhaps you could temporarily move the queue to a ramdisk mount?

mkdir /mnt/pframqueue
mount -t tmpfs -o size=512M tmpfs /mnt/pframqueue
service postfix stop
mv /var/spool/postfix/* /mnt/pframqueue/
<<<adjust 'queue_directory' in main.cf to /mnt/pframqueue>>>
service postfix start

Do the opposite once you're done.

IMHO that's more trouble than it's worth, especially if something goes screwy in the mv

Solution 2:

Use this to stop (pause) and start delivery of outgoing mail again:

sudo postconf -e defer_transports=smtp; sudo postfix reload
sudo postconf -e defer_transports=; sudo postfix reload; sudo postfix flush

This should be applicable to other transports as well.

Source: nixtips.net

Solution 3:

Just shut down postfix. Any legit sending server will queue your mail and retry after a time delay if it is not able to contact your server. As long as your maintenance is short, say under 6 hours, your chances of losing mail are very small.