SourceFiles.org - Use the Source, Luke
Home | Register | News | Forums | Guide | MyLinks | Bookmark

Sponsored Links

Latest News
  General News
  Reviews
  Press Releases
  Software
  Hardware
  Security
  Tutorials
  Off Topic


Back to files
                                 Spamhammer-0.1
                                   06/30/2002

WHAT IS SPAMHAMMER?


Spamhammer is program that monitors your pop3 account for email. When email is found, a comparison is made on the "From" field of the email to addresses in in the file addresses.sp. If a match is not found, Spamhammer will delete the message from the server (optional) and send a reply to the email indicating the mail was not delivered (optional).

Spamhammer is not going to be well suited for a lot of people. For instance, if you get the mail for "feedback@mywebsite.org", you are never going to know who is sending you mail. Your kind of S.O.L. But, for just regular people using the web to email friends and stuff, it should work pretty good.

REQUIREMENTS

First of all, you will need perl. You can get this from http://www.perl.com/pub/a/language/info/software.html

You will also need the Mail::Sender module by Jan Krynický http://www.cpan.org/authors/id/J/JE/JENDA/Mail-Sender-0.7.14.1.tar.gz for the auto-replying feature.

Another required perl module is Mail::POP3Client and can be snagged from http://www.cpan.org/authors/id/SDOWD/POP3Client-2.10.tar.gz

INSTALLING

untar the spamhammer tarball in any directory you wish.

tar xvfz spamhammer-0.1.tgz

the directory "spamhammer-0.1" will be created from the tar file.

::addresses.sp::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Open the file addresses.sp in a text editor and add any email addresses you want to accept. You can also simply use the domain name part of the email address (to accept any mail from that domain), or just the username, such as "foo" in "foo@bar.com". The perl script "scrounge.pl" is included if you want to parse email addresses out of file (such as your Sent mailbox in mozilla). scrounge was a last minute hack, so it can use some enhancements. Example addresses are in addresses.sp for example.

scrounge.pl /home/me/.mozilla/me/asdfgh.slt/Mail/mail.server.com/Sent

will spit out email addresses to the console. Redirect into a textfile if desired. You will most likely need to edit the output as scrounge needs refinement. scrounge attempts to eliminate duplicate addresses.

::reply.sp::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Open the file reply.sp in a text editor. This is the message that will be included in the body of the email when Spamhammer replies to a message it deleted from the server. This option is disabled by default because you must supply an alternate email address in case the reply bounces. You must be careful when enabling this option because it is possible to setup and endless cycle of replying and bouncing if the reply bounces and you aren't accepting email from the server the reply bounced from. If you don't know what I mean, just leave this option alone. Either way, season reply.sp to taste, and if you know what you are doing, enable the option in spamhammer.pl:

$AUTO_REPLY = 0; << change to 1 to auto reply $BOUNCEADDY = 'a_real_address@yahoo.com'; << this must be a real addy.. go to yahoo

and get one.

::deleted.sp::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: This is the log file Spamhammer keeps of deleted messages. The format is below. There are some default entries in the existing one for example purposes.

date and time number and size of message sender subject

Sat, 15 Jun 2002 07:26:36 Message #001 00000387 bytes: foo@bar.com test

You should check this periodically to see if Spamhammer has nuked any email from people you wanted to accept, but didn't have in addresses.sp

Also, beware of the subject line. This is going to be sanitized somehow in the next version so control characters and crap like that don't end up in the log file.

::inbox.sp::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: This is the file Spamhammer will download your mail into if the "From" address is matched in addresses.sp. I played with it for a while, but didn't test it extensively. The idea is, invalid email is left on the server for your review, and your email client feeds off inbox.sp instead of the pop3 server directly. This is also an option you can enable in spamhammer.pl:

$DOWNLOAD_VALID = 0; << change to 1 to download mail.

another option you may want to enable is to delete the mail from the server after downloading it. Again, I haven't tested this fully.

$DELETE_ON_DOWNLOAD = 0;# << change to 1 to delete

POP3 INFORMATION

This is where you setup your username for your pop3 acccount, your mail server, and your password. If you leave $USER and $PASSWORD set to "ask", spamhammer will ask you for your username and password so you don't have to leave it laying in plain sight in a text file.

$BOUNCEADDY = 'a_real_address@yahoo.com'; << forged "From:" field in reply

$MYEMAIL    = 'me@mydomain.com';          << used for auto-replying in body of message
$SERVER     = "mail.server.com";          << your pop3 server
$USER       = "ask";                      << your pop3 account login name
$PASS       = "ask";                      << your password for your pop3 account

You may also want to customize the timeout between email checks: $SLEEP = 60;

RUNNING SPAMHAMMER

After setting up all of the above to your liking, simply cd to the spamhammer directory and type

./spamhammer-x.x.pl

(where -x.x is the current version number of spamhammer)

Spamhammer will ask you for a username and password if $USER and $PASS is set to "ask" and then it will go to work connecting to your email server and begin checking your email. A status line will be printed showing the current state of your email.

-=[ 0 message(s) on mail.server.com for foobar 0 deleted 0 AutoReplied ]=-

0 messages means there's nothing on the server 0 deleted means nothing has been deleted since you started spamhammer 0 AutoReplied means spamhammer has not replied to any unknown email since it was started.

Below is the output when email is found waiting on the server. The '*' indicates mail from a source where no match was found (invalid).

-=[ 3 message(s) on mail.server.com for foo 0 deleted 0 AutoReplied ]=-

  1. foo@bar.org message logs valid:1 size:5680
  2. me@mymail.com forwarded information valid:1 size:6667

The output will continue indefinately, checking every $SLEEP seconds. Here, Spamhammer is not setup to automatically delete invalid messages, a handy way to check if all your addresses are entered into addresses.sp. hit CTRL+C to terminate spamhammer.

OTHER STUFF

Spamhammer doesn't check to see if it has an active connection to your email account. There is a call in Mail::POP3Client to check this, I just never got around to it. All you get in the status display is "-1" for the messages.

It would be pretty easy to add some kind of sound support to spamhammer so it would play a sound when new mail is found, or when replied, or deleted.. etc.... I just didn't put it into this version.

Some kind of gui-window-icon-status-kde/gnome/xlib thingy for showing the status instead of the console output would be nice too.

At some point, I'd like to add a keyword to check for in the subject of the email on the server. If someone gets an autoreply, they could include a keyword in the subject that spamhammer would check for even if the email address is not in addresses.sp. This would allow someone to re-send their message and not get 'hammered if you haven't had a chance to add them to addresses.sp. I suppose another file could be setup with keywords of your choice and every hour or day or whatever, a different keyword would be the accepted subject keyword of the day.

I'd like to put some kind of size limit feature into spamhammer also, and/or something to deal with attatchments (viruses). I suppose the mime-type could be scoped-out or something.. To those of us running *nix it's not much of a problem (virii) ...yet

Also, I'm thinking of adding a feature to scan a "Sent" file when an invalid address is found. As I use Spamhammer, I'm finding out ways to enhance it. Scanning the "Sent" file (folder) for an email address not in addresses.sp yet, would be nice.

THANKS

thanks to the authors of:
perl
Mail::Sender
Mail::POP3Client,
Linux maintainers/coders/hackers
authors/maintainers of Nedit
Berry Bros coffee (Higlander Grog..mmmm)

Their hard work made this a lot easier to code.

HISTORY

06/30/2002 - initial spamhammer-0.1 release


Sponsored Links

Discussion Groups
  Beginners
  Distributions
  Networking / Security
  Software
  PDAs

About | FAQ | Privacy | Awards | Contact
Comments to the webmaster are welcome.
Copyright 2006 Sourcefiles.org All rights reserved.