Suitable rate limiting will prevent most forms of computer abuse. It even limits spam in a mail server too. If you configure a mail server to wait 10 seconds before answering any incoming connection, the incoming spam will drop to almost nothing, while legitimate messages will be unaffected.

One can also use the above iptables rate limiting rule (6/minute) for a mail server instead of hacking the code. The spammers will think that your server is a horrible crummy overloaded useless piece of junk and go away, while legitimate mail servers will feel an overwhelming pang of enmity and will wait patiently for the poor dear to respond.