Stopping the Joe Job Bounces

jbisbee on 2003-09-06T03:15:35

Like many of you I have my own domain (jbisbee.com) and some time ago someone harvested a bunch of domains and started Joe Jobbing them. They did this by using

randomcrap@jbisbee.com
When this first happened it really sucked because my poor filters weren't ready for it and not only did I get bounces, I got people replying to the e-mail and complaining to me about the spam I didn't even send.

Up until this point, I just said screw it and decided to let Spam Assasin and my Email::Filter do the work. I've been thinking about how to stop from even seeing the bounces and I've determined that if I could actually get a list of all the aliases I've used over the years, I could block any mail not set to those know addresses. So the task at hand, parse all my mboxes and pull out any address @jbisbee.com to build a master list.

I tried a couple of mbox parsers, but settled on Mark Overmeer's wonderful (and huge) Mail::Box because of all the OO goodness. I also used File::Find::Rule to build a list of all my mboxes. With these modules, I was able to put together the follow script to generate a list of the aliases I use with my jbisbee.com domain.

#!/usr/bin/perl -w
use strict;
use File::Find::Rule;
use Mail::Box::Manager;

my $directory = "/home/jbisbee/mail";
my $domain    = quotemeta 'jbisbee.com';

# to count the number of occurences for each address
my %aliases = ();

# get all your mboxes within your mail directory
my @mboxes = File::Find::Rule->file()
                             ->name( '*' )
                             ->in( $directory );

my $mgr = Mail::Box::Manager->new;
for my $folder_name (@mboxes) {
    my $folder = $mgr->open( folder => $folder_name );
    foreach my $message ( $folder->messages ) {

        # Mail:;Address objects for to, cc, and from
        for my $ma ( $message->to,
                     $message->cc,
                     $message->from ) {
            if ( $ma->address =~ /$domain$/i ) {
                $aliases{ lc $ma->address }++;
            }
        }
    }
    $mgr->close($folder);
}

for my $email ( sort { $aliases{$b} <=>
                       $aliases{$a} } keys %aliases ) {
    print "$aliases{$email}\t$email\n";
}
Now armed with this list I have setup my mail aliases file to only accept mail to those addresses. Never again will I have to deal with bounces to e-mails I never sent and never again will I have to deal with people asking me to remove them from a spam list I don't have.