temporary block incoming messages to specific user

Paul Kudla (SCOM.CA Internet Services Inc.) paul at scom.ca
Wed Apr 20 13:08:51 UTC 2022


this is handled in a couple of different ways


please note this is only for virtual users and assumes you are running 
postfix/dovecot


through postfix (first)

see main.cf :

# SOFT BOUNCE
#
# The soft_bounce parameter provides a limited safety net for
# testing.  When soft_bounce is enabled, mail will remain queued that
# would otherwise bounce. This parameter disables locally-generated
# bounces, and prevents the SMTP server from rejecting mail permanently
# (by changing 5xx replies into 4xx replies). However, soft_bounce
# is no cure for address rewriting mistakes or mail routing mistakes.
#

soft_bounce = yes


the above option in postfix will continually try to deliver to the end 
user, if the user does not exist it will continue trying without any 
bounceback to the sender.

this was built into postfix mainly for mail migrations between servers 
where the dovecot, cyrus server upgrades etc came into play

but should work for your situation.


next on the dovecot side (user database queries)

# cat dovecot-pgsql.conf
driver = pgsql
connect = host=localhost port=5433 dbname=scom_billing user=pgsql 
password=Scom411400
default_pass_scheme = PLAIN

password_query = SELECT username as user, password FROM email_users 
WHERE username = '%u' and password <> 'alias' and status = True and 
destination = '%u'

user_query = SELECT home, uid, gid FROM email_users WHERE username = 
'%u' and password <> 'alias' and status = True and destination = '%u'

#iterate_query = SELECT user, password FROM email_users WHERE username = 
'%u' and password <> 'alias' and status = True and destination = '%u'

iterate_query = SELECT "username" as user, domain FROM email_users WHERE 
status = True and alias_flag = False


this file reflects how to query the database tables etc

note the status=true above etc, i use this to specify if the account is 
active and ok or not

if this flag is set to false, dovecot will consider this user non active 
and not allow delivery locally.

mainly used for billing but will sufice

also note i use an alias flag (from the cyrus days) to forward emails 
off to another actual active account

i am still streamlining that internally but thought i should explain why 
it is there

please note iterate_query is used for the replication users (doveadm 
user '*') query - not needed if you dont run replication but wont hurt 
anything if it is there.









Happy Wednesday !!!
Thanks - paul

Paul Kudla


Scom.ca Internet Services <http://www.scom.ca>
004-1009 Byron Street South
Whitby, Ontario - Canada
L1N 4S3

Toronto 416.642.7266
Main 1.866.411.7266
Fax 1.888.892.7266

On 4/20/2022 8:39 AM, Marc wrote:
> Is it possible to block incoming messages from being delivered to a specific user in such a way that the MTA will try again later. I do not want these message to bounce. (eg while doing some manual maintenance on the user)?
> 
> 
> 
> 
> 
> 
> 
> 


More information about the dovecot mailing list