postfwd rate limit examples


Below you will find some rate limit examples. Please read the documentation for more information.


Throttle unknown clients to 5 recipients per 5 minutes:

id=RULE001
	client_name==unknown
	action=rate(client_address/5/300/450 4.7.1 only 5 recipients per 5 minutes allowed)


Do not allow more than 20MB per day for recipients of example.org:

id=RULE002
	recipient_domain==example.org
	action=size(recipient/20971520/86400/REJECT only 20mb per day for $$recipient)


Do not allow more than 20MB or 1000 recipients per day for users alice and bob:

id=RULE003
	sasl_username=~/^(alice|bob)$/
	action=size(sasl_username/20971520/86400/REJECT only 20mb per day for $$recipient)
id=RULE004
	sasl_username=~/^(alice|bob)$/
	action=rcpt(sasl_username/100/86400/REJECT only 100 recipients per day for $$sasl_username)


Internal message hub with different classes:

# Class 1: high volume clients
# - per mail: max 30MB, max 200 concurrent recipients
id=CLASS100; client_address=table:/etc/postfwd/class1.cf; action=jump(CLASS101)

# Class 2: medium limited access
# - per mail: max 10MB, max 50 concurrent recipients
# - rate limit: 1000 recipients or 100MB per day
id=CLASS200; client_address=table:/etc/postfwd/class2.cf; action=jump(CLASS201)

# Class 3: very tight limits
# - per mail: max 4MB, max 10 concurrent recipients
# - rate limit: 100 recipients or 20MB per day
id=CLASS300; client_address=table:/etc/postfwd/class3.cf; action=jump(CLASS301)

# Does not fit anywhere? REJECT
id=DEFAULT; action=REJECT please contact postmaster@example.org

# Class 1
id=CLASS101; size>=31457281; action=REJECT max message size is 30MB - you had $$size bytes
id=CLASS102; recipient_count=>201; action=REJECT max recipient count is 200 - you had $$recipient_count recipients
id=CLASS199; action=DUNNO

# Class 2
id=CLASS201; size>=10485760; action=REJECT max message size is 10MB - you had $$size bytes
id=CLASS202; recipient_count>=50; action=REJECT max recipient count is 50 - you had $$recipient_count recipients
id=CLASS203; action=rcpt(client_address/1000/86400/REJECT limit of 1000 rcpts per day for client $$client_address reached)
id=CLASS204; action=size(client_address/104857600/86400/REJECT limit of 100 MB per day for client $$client_address reached)
id=CLASS299; action=DUNNO

# Class 3
id=CLASS301; size>=4194305; action=REJECT max message size is 4MB - you had $$size bytes
id=CLASS302; recipient_count>=10; action=REJECT max recipient count is 10 - you had $$recipient_count recipients
id=CLASS303; action=rcpt(client_address/100/86400/REJECT limit of 100 rcpts per day for client $$client_address reached)
id=CLASS304; action=size(client_address/20971520/86400/REJECT limit of 20 MB per day for client $$client_address reached)
id=CLASS399; action=DUNNO