blacklisting spammer addresses

Here's a script to blacklist email addresses from which you have received spam.

#!/bin/bash
ssh root@your.mail.server "echo '$1' >> /etc/exim4/local_sender_blacklist"
ssh root@your.mail.server 'kill -HUP `cat /var/run/exim4/exim.pid`'

Save this to bin/blacklist, make it executable:

chmod 755 bin/blacklist

and run it like this:

$ blacklist spammer@foo.bar.com

or, from within mutt using the following in .mutt/muttrc

# keep headers in piped messages.
unset pipe_decode

# blacklist
macro index,pager B '<pipe-message>extract-address | blacklist'

and, as ~/bin/extract-address

#!/bin/sh

grep envelope-from | head -n 1 | cut -d '<' -f 2 | cut -d '>' -f 1

and, as ~/bin/blacklist

#!/bin/sh

SERVER=your.server.goes.here
ADDRESS=$(cat /dev/stdin)

ssh root@${SERVER} "echo '$ADDRESS' >> /etc/exim4/local_sender_blacklist"
ssh root@${SERVER} 'kill -HUP `cat /var/run/exim4/exim.pid`'

Whitelist

#!/bin/bash
ssh root@your.mail.server "echo '$1' >> /etc/exim4/local_sender_whitelist"
ssh root@your.mail.server 'kill -HUP `cat /var/run/exim4/exim.pid`'

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 17, 2019