On 11/09/2021 16:40, Nick Howitt wrote:



On 11/09/2021 14:03, Nick Howitt wrote:



On 11/09/2021 13:57, Nick Howitt wrote:



On 11/09/2021 13:24, Kristian wrote:

On 11/09/2021 13.43, Nick Howitt wrote:
As part of a backup script for cyrus-imapd, I'd like to temporarily stop postfix delivering mails to cyrus-imapd and to just queue them. If it is

I believe you can do this with check_recipient_access, e.g.:

/etc/postfix/main.cf:

   smtpd_recipient_restrictions =
     [..]
     check_recipient_access pcre:/etc/postfix/recipient_checks.pcre
     [..]

/etc/postfix/recipient_checks.pcre:

   /.*\@.*/ HOLD

This should accept all incoming mail, and hold it in the queue that you can later release with postsuper.

You'll need to reload postfix to have it re-read the .pcre file. Other lookup tables probably work too.


Hmm. I've tried:
smtpd_recipient_restrictions = check_recipient_access pcre:/etc/postfix/recipient_checks.pcre, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_invalid_hostname, reject_unauth_pipelining, reject_unknown_recipient_domain, reject_rbl_client zen.spamhaus.org, check_policy_service unix:/var/spool/postfix/postgrey/socket

So putting your restriction at the beginning.

cat /etc/postfix/recipient_checks.pcre
/.*\@.*/ HOLD

I've tried restarting and reloading postfix, and mails still are being delivered internally immediately.

Nick
My bad. I'd edited main.cf but not saved it. Your method works, thanks.

I would still like to see if something with postconf -o can work but my line is stupidly long to apply like that.
Looking at this further and looking at the order of processing, would it be better to put this in header_checks? My logic is that if I put it in my smtpd_recipient_restrictions, I have to put the filter as the first filter or local delivery bypasses it, but by doing this, when active, all e-mails bypass the other restrictions. If I put it in header_checks, then all the earlier smtpd_recipient_restrictions are still active.

Taking this logic further, I could put it in body_checks which I don't normally use. I could then add the body checks on the fly by using "postconf -o body_checks=regexp:/etc/postfix/body_checks"

Is this viable?

Nick
Partly answering my own question, "postconf -o body_checks=regexp:/etc/postfix/body_checks" seems to do the right thing in that the output of the command shows it is set, but it does nothing to the running config. As I don't want to write to main.cf because ClearOS watches the file and fires off an event if it changes, I've settled for appending a filter to /etc/postfix/header_checks and reloading postfix to hold all mail and reversing it after I've done the backup, then releasing anything that is held.

Thanks for pointing me in the right direction.

Nick

Reply via email to