Disposable email service is an online service where you can get a temporary email address or an anonymous email account for signing up on certain websites that require email verification.
Why does such service exist?
Many people are concerned that their email will get compromised if they handed out their email address to a third party website. They might get unnecessary promotion materials or more commonly called spams. They could create a temporary Yahoo or GMail account for that purpose but it requires too much effort or too many steps for such a simple thing.
For that reason, disposable email service is created. People can turn to a disposable email service to test the website without revealing their identity. Or sometimes people just want to get the free stuff offered by the third party website by exchanging their email without long-term commitment. They don’t have to worry about creating too many email addresses.
There are many such services available online.
- maildrop.cc (open source, relies on Amazon Web Services)
- mailsac.com (open source, relies on Node.js and Mongodb)
- github.com/synox/disposable-email (open source, relies on piping email to PHP script and MySQL tables)
- code.google.com/p/pookmail/ (open source, relies on MySQL tables)
- gentlesource.com/temporary-email/ (commercial source code that you can buy)
- 2prong.com (open source which is dead now, relies on piping email to PHP script and MySQL table)
As you can see some are open sources. I wanted to host my own disposable email service as a simple project. So I looked around all the available open source solutions.
Most have complicated implementation like requiring Amazon Web Service to run which cost money, or requiring Node.js which my web hosting provider does not allow unless I upgrade to a private server (which also cost money), etc.
Among the open source projects, 2Prong’s implementation is the simplest (also it contains the least code). However, there are still some technical challenges to overcome: piping email to PHP using a .forward file. I could not get it to work on my server (Dreamhost) after following the guides provided like Email to Script and Shell-linked Email.
I spent many hours trying and testing different configurations but to no avail. Dreamhost does not provide support to such feature (email to script) and my conclusion is that in order to make it work, I need a private server. So I gave up.
Leveraging IMAP (Internet Message Access Protocol)
After cooling down, I realized that I could leverage the IMAP protocol which Dreamhost is using for handling email. In fact, all managed email accounts created on the server are using IMAP. I just need to be able to login to the webmail using PHP through IMAP and the job is done. There is indeed such PHP function that allow me to connect and read mail through IMAP for example imap_open and sample code here and sample code.
With this new insight, I created a catch-all email for my reducespam.org domain. A catch-all email will intercept every email sent to that domain. I setup the appropriate setting like only keeping the messages for 2 days or no more than 200 messages at a time etc to avoid getting too many spams.
Then I proceeded to update 2prong source code by removing the dependency on email piping and MySQL table (since the emails are now being handle by IMAP).
Simplest disposable email service solution
After simplifying the source code, these are the new requirements for running a self-hosted disposable email service:
- no virtual private server (VPS)
- no Amazon Web Service (AWS)
- no Node.js and MongoDB
- no email piping
- no .forward or .alias files
- no cronjob to delete mails
- not even MySQL table
- what you need is a web host with IMAP email account
The following the is the service that I am hosting at reducespam.org.
You can try it! 🙂
Source code for download Reduce Spam Source Code 150610. There is a readme.txt file with instructions on how to make it work on your server.