The World of Mayukh Bose

<< Back to Main Page Mayukh's world: e-mail me | about
Mayukh's World: Perl Software: Tuesday, July 16, 2019
My Free Software
  • Delphi/C++ Builder
  • Pocket PC
  • FreeSpeech Chat
  • C/C++ Freebies
  • Perl
  • Python
  • Ruby
  • My Perl Code
  • Free Perl Software e-mail me - 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:
    • 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 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 and emails sent to this address automatically get forwarded to the real address.
    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.

    System Requirements

    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
    • 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

    Setup Instructions

    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
    • Profit!

    How the Script Works

    The script works as follows:
    1. First check to make sure that another copy of the script is not already running
    2. Log into the POP mail box using the specified login and password and fetch all the emails from the box.
    3. For each email, check the To: address.
    4. 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.
    5. 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.

    ^Up to Mayukh's World^

    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 ( as well.