Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Don't ask to ask, just ask

Easy blacklister for qmail

by liz (Monsignor)
on Aug 20, 2003 at 22:54 UTC ( #285316=snippet: print w/ replies, xml ) Need Help??

Description: This piece of code is intended for those people that are using qmail, and which have set up a .qmail-default to have all email (other) addresses of a domain wind up in the same mailbox.

This behaviour has become very annoying when spammers just get a valid domain name and just start prefixing names they found somewhere else. You will then always get these in your mailbox. And because they don't bounce, some spammers will use that knowledge to conclude it's a valid email address and start using it again.

Of course, blacklisting these email addresses is pretty straightforward in qmail: just add the appropriate .qmail-.... file. But of course, we're lazy, so I devised a lazier way to do this.

Instead of having to login to a shell and go to the right directory and start creating the file, the only thing you need to do is do a "send again" of an offending email. You will receive that email then once more, but never again will you receive email on that address.

Theory of operation: add the line:

as the first line to your .qmail-default file. Keep the rest of the lines in there. Whenever a mail is received with "" as the sender of the email, then it will put the addressee on the blacklist (by creating a .qmail-addressee and .qmail-addressee-default file that drops the email).

Lifting the blacklist is as easy as removing the appropriate .qmail-addressee files.

Put this code in a file named "blacklist" and make sure it is executable with your uid. You can name it anything you want and put it anywhere you want, as long as you adapt the first line in the .qmail-default file accordingly.

Thanks to batkins for unknowingly inspiring me to do this.



exit 0 unless $ENV{'SENDER'} eq shift;    # deliver normally if not th
+e master

my $dot = $ENV{'LOCAL'};
exit 0 if $dot =~ m#[^\w\-\.]#;           # give up if strange charact
+ers here
exit 0 unless $dot =~ s#^$ENV{'USER'}-##; # drop user, fail if fails
$dot = ".qmail-$dot";

foreach ('','-default') {                 # bare + extra garbage in na
    next if -e ".qmail-$dot$_";           # we don't want to overwrite
    open OUT,">$dot$_" or die "Could not open '$dot$_': $!\n";
    print OUT "#\n";                      # enough for qmail to waste
    close OUT;

exit 0;                                   # deliver this one normally
Comment on Easy blacklister for qmail
Download Code
Re: Easy blacklister for qmail
by Intrepid (Deacon) on Aug 26, 2003 at 06:36 UTC

    ++! Insane clapping, applause. Applause. We need more great ideas like this.

    I only wish now that I could stumble across something like this for exim, since I am an exim user, not a qmail user. Nevertheless, kudos for inventing something good. These MTAs are as a bunch Limp and Hard to Manage (ref. "Earth Girls Are Easy", film) and so anything that makes them easier to use is a great thing in my book.


    use PerlMonk::Tye qw(:wisely);

Back to Snippets Section

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://285316]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-04-19 08:02 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (478 votes), past polls