temporarily suspend mail delivery to a specific domain

With postfix and cron delivery of new mail messages may be certain times quite easily prevented. It can for example be prevent from that emails are delivered via push to inopportune times to a user.

Add a hash-table in /etc/postfix/main.cf to smtpd_recipient_restrictions:

check_recipient_access hash:/etc/postfix/hold

In the file /etc/postfix/hold all domains and email addresses can be entered which may currently receive no emails.

example.com HOLD
postmaster@example.de HOLD

After changes to the file you must run

postmap hash:/etc/postfix/hold

so that postfix accepts the changes and (re)creates the db-file.

In order to process the messages resting on hold, you must run

postsuper -r ALL

If, for example, mails from 06:00 pm – 07:00 am should not be delivered, a cron script can be executed at 06:00 pm

sed -i 's/^#//g' /etc/postfix/hold
postmap hash:/etc/postfix/hold

Thus # is removed in all lines of /etc/postfix/hold and postfix creates the lookup table again.

The service is enabled again when # is placed in the hold file at the beginning of each line (this comments a line). At the same time all hold-mails , will be released. The script would then run at 07:00 am.

sed -i 's/^/#/' /etc/postfix/hold
postmap hash:/etc/postfix/hold
postsuper -r ALL

Leave a comment

Your email address will not be published. Required fields are marked *