Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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:

|./blacklist yourfrom@address.com
as the first line to your .qmail-default file. Keep the rest of the lines in there. Whenever a mail is received with "yourfrom@address.com" 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.

Liz

#!/usr/local/bin/perl 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 +mes 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

In reply to Easy blacklister for qmail by liz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-18 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found