Hello list I need your experience here to see if "my" solution is good or bad :-) Background: We have a postfix setup which can only check users quota after postfix accepted the message. As you can imagine we produce a lot of backscatter. Until now the procedure was to manually check mailq and delete mails from "well-known" users which never clean up their mailboxes (do not blame me about that, I just started to work there 4 weeks ago ;-) ) So I thought that must be solved somehow easier and more automatically. My basic idea is to regularly scan the mailq for mails defered by "overquota". From these mails in queue I fetch the recipients and add them to a recipient-restriction file for postfix. So postfix can reject such mails before the queue.
<<snip>> #!/bin/bash LIMIT=10 TFILE=$(mktemp) mailq | tail -n +2| awk 'BEGIN {RS = ""} /over quota/ {print $NF}' | grep -v maildrop: | sort -n | uniq -c | sort -nr | awk '{if($1> '"$LIMIT"') print $2}' > $TFILE while read line ; do echo "$line 550 Account $line is overquota and cannot receive mails" >> /root/overquota done <$TFILE cp -f /root/overquota /etc/postfix/ postmap /etc/postfix/overquota postfix reload <</snip>> The overquota is in main.cf as check_recipient_access hash:/etc/postfix/overquota within the smtpd_recipient_restrictions. Is it "save" to do something like the above? Especially could it somehow happen that my mailq... line matches something wrong? My main concern is to write something "wrong" in the overquota file and break postfix (like rejecting everything or something similar) Thanks for any hints and enjoy the weekend tobi