What I do is install fail2ban on my servers. It bans IPs who fail to connect too many times in a given time period. I don't have to worry about banning individual IPs after that.
The problem was that the rule I was trying to use was below all my postfix rules and so the traffic was passed before reaching it. I have installed and configured fail2ban, which has stopped the erroneous login attempts. Thank you everyone for your help and suggestions.