Host Your Own Email: Easy Disposable Addresses

Category: Python   Tags: , ,

If you’ve been on the Internet for any extended period of time, you’ve probably felt annoyed at all the websites that require your email, and sometimes even put annoying checks on them.

Common Annoyances

  1. Requiring an email address and then sending a confirmation link.
  2. Websites that send their “free information” through email in a ploy to get your email address.
  3. Websites that reject all the free email providers. (You must provide a real email address, why is a free one not real??)

I hear half of you saying “you can use free disposable email websites”. This is true. A simple search on Google will bring up a long list of them.

However, I’ve increasingly found the websites to be offline, blocked by websites, or not receiving any email whatsoever.

So why not host your own email server? Well I looked around online, and found myself completely annoyed at the bulkiness and difficulty of setting up a simple catch-all, so I decided to make my own and share it with all of you.


Solution

The following code is written in Python. If you do not have Python, you may download the Windows executable below.

Click here to download “Easy Email Host: Enhanced Windows Version including source code”.

import smtpd, time, asyncore, os, sys, urllib, re
 
class Receiver(smtpd.SMTPServer):
    def process_message(self,peer,sender,recipient,data):
        print 'Received Message To %s From %s' % (recipient, sender)
 
        if 'mail' not in os.listdir(os.getcwd()):
            os.mkdir('mail')
 
        try:
            f = open('mail/%s.txt' % time.time(), 'w')
            info = "%s\r\n%s\r\n%s\r\n%s" % (peer, sender, recipient, data)
            f.write(info)
        except:
            print "Error: could not write to disk."
        finally:
            f.close()
 
def loop(host):
    a = Receiver(host,('',0))
 
    try:
        asyncore.loop(timeout=0.5)
    except KeyboardInterrupt:
        print 'Abort'
        sys.exit(0)
 
if __name__ == '__main__':
    print 'Easy Email Host by codexon.com'
    print 'Emails are saved in the "mail" directory'
    print 'Press Crtl+C to quit\n'
    loop(('0.0.0.0',25))

Here is a picture of the enhanced version in action which simply includes automatic external IP address locating and a check to make sure your port is open.

easyemail

Here are the instructions.

  1. Open your firewall or NAT at port 25.
  2. Run the program.
  3. Emails are saved in the “mail” directory as text files.

If for some reason you don’t have a “domain name” for your IP (which almost everyone has including Comcast and Verizon customers), you may go to http://www.dyndns.com/ and point one of their domains to you IP address for free. This is also useful for getting different email names.

I used this script to create multiple Facebook accounts back when they required email addresses from an Ivy. It definitely works.

  • Reddit
  • HackerNews
  • Twitter
  • DZone
  • del.icio.us
  • FriendFeed
  • StumbleUpon
  • RSS

Related posts:

  1. Hot code swapping for servers not written in Erlang
  2. Clearing Passwords in Memory with Python
  3. A Better Python Reload
  4. Finding the Current Address in a C Program
  5. How to customize Eclipse to be the best Python IDE with PyDev

6 Comments  »

  1. Kamran says:

    hi unable to download from the link above. would like to learn from it easy email host sounds great

  2. Ian says:

    “If for some reason you don’t have a “domain name” for your IP (which almost everyone has including Comcast and Verizon customers)”

    I am a Comcast customer; how do I figure out what this “domain name” is? Does Comcast really have something akin to dyndns?

  3. vinay says:

    To receive e-mail you need MX record in dns for that domain name pointing to your IP. Definitely no ISP sets this up for you.

    • admin says:

      All email senders will default to the A record if no MX record is present. There is no need for an MX record.

RSS feed for comments on this post, TrackBack URI

Leave a Comment

(Cookies must be enabled)