15

Using Postfix and custom transports I can manage delivery speeds depending on the recipient's domain. (For example, I send max one message per second to *@hotmail.com)

I also use similar rules to block bad destinations (htmail.com is blocked right away, avoiding many loops in the queue).

However, I'd like to temporarily suspend mail delivery to a destination for 24 or 48 hours (mails to *@gmail.com suspended, everything else delivered). Messages would queue up during this time, and would be delivered only when I want by changing the config.

Does anyone know how to do that ?

Thanks

3 Answers 3

25

Put messages in a HOLD state

/etc/postfix/main.cf:

smtpd_recipient_restrictions = 
    ...
    check_recipient_access hash:/etc/postfix/hold

/etc/postfix/hold:

gmail.com        HOLD
blah.com         HOLD

Make sure you run postmap hash:/etc/postfix/hold whenever you update the file.

If you want to release all messages on hold, use postsuper:

# postsuper -H ALL
4
  • Looks like it doesn't work after all. Mail is immediately submitted. Maybe because I send mail from $mynetworks ? REJECT and DISCARD don't work either, I had to go with transport's error:
    – Julien
    Dec 16, 2009 at 17:05
  • Ok, my bad, mail sent locally with mailx is not checked because it's not sent to smtpd. Works very well :)
    – Julien
    Dec 16, 2009 at 18:02
  • If you want to temporarily hold all outgoing email you can use a static type instead: check_recipient_access static:HOLD. An inline type might also be useful to hold a few domains without the need for a hash. postfix.org/DATABASE_README.html#types
    – TCB13
    Jun 18, 2020 at 13:36
  • Note: if you're forcing clients to send email via submission you might have different submission rules written at master.cf and your email still might get delivered. Check what's being applied to your submission and add the check_recipient_access to the appropriate places, in my case it was smtpd_mua_relay_restrictions.
    – TCB13
    Jun 18, 2020 at 13:39
3

You can do this with a transport map:

gmail.com defer:

0

To put on hold for specific domain:

postqueue -p | awk 'BEGIN { RS = "" } { if ($7 == "[email protected]" ) print $1 }' | tr -d '!*' | postsuper -h -

To release for a specific domain:

postqueue -p | awk 'BEGIN { RS = "" } { if ($7 == "[email protected]" ) print $1 }' | tr -d '!*' | postsuper -H -
1
  • Just no. The $7 will match the Sender Email address on the same line as the queue ID. The recipient email address is on the next line, and it needs a domain match, not email match. Apr 12, 2014 at 11:00

You must log in to answer this question.

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