Perl Software: forwardmail.pl
Sunday, August 28, 2016
forwardmail.pl - Email Forwarder and Anonymizer Script
Add anonymous email services to your website
Ever felt the need to provide anonymous e-mail services for your website? There
are several reasons you could have a need for something like this:
If you do something like this, then this script is exactly what you're looking
for. Best of all, it is released with full source and a very permissive license
that allows you to make your own modifications if you like.
- You run a site that allows users to advertise goods for sale. For privacy
reasons, you don't want to display the seller's e-mail address. People who
want to contact a seller send email to anon-XXX@yourdomain.com and the emails
get forwarded to the seller's real e-mail address
- You run an email-forwarding service, where registered users get an anonymous
email address (such as my-email-XXXX@yourdomain.com) and emails sent to
this address automatically get forwarded to the real address.
You'll need the following:
- UNIX-like system - Linux, FreeBSD, OpenBSD, NetBSD etc. The code can be easily modified
to work on Windows. Contact author for details.
- perl modules - DBI, Net::POP3, Email::MIME, Mail::Sendmail.
- Some kind of database to store the real email addresses. MySQL or Postgres are suggested, but practically anything else can be used as well.
- Access to set up a cronjob and a default email address.
- POP email + some editing skills
Please follow the steps below:
- Set up a separate catch-all e-mail account for your domain
- Download the code and unzip it.
- Modify the script according to your server and login details
- Upload the script to your server
- Set up a cron job to run your script every few minutes or so
How the Script Works
The script works as follows:
- First check to make sure that another copy of the script is not already running
- Log into the POP mail box using the specified login and password and fetch
all the emails from the box.
- For each email, check the To: address.
- If the To: address begins with
anon-XXXX@ (where XXXX is a number), it extracts XXXX from the address
and queries the database for the real e-mail address. It then forwards
the email on to the real address. If you want to use a different prefix address
instead of anon-XXXX@ (for instance, fakemail-XXXX@ or mymail-XXX@), you can
easily modify the script to do this.
- If the To: address doesn't begin with anon-XXXX@, it forwards the email to
another default address. You can change this default address in the script
as well. Typically, this should go to a regular email address that the
owner of the website uses.
Copyright © 2004 Mayukh Bose. All rights reserved.
This work may be freely reproduced provided this copyright notice is preserved.
OPTIONAL: Please consider linking to this website (http://www.mayukhbose.com/
) as well.