by Oren Geva
How To Setup Your Own Disposable Email Server
Disposable email services are online services that provide temporary email addresses for registering or signing up on websites that require email verification.
The purpose of these services is that you can avoid exposing your own email address to potential SPAM, especially if you just need the service for a short period of time.
Disposable email services are also useful in software development and testing, as many software products require email verification themselves. Using real email addresses in the context of software development or testing is cumbersome and annoying. Many teams around the world use temporary disposable email services for testing their own software products.
Each has their own interpretation of the theme, but one of the things that makes AHEM unique is that AHEM’s code is freely available on GitHub as open source, allowing a user to download and set up their own temporary mail server.
But why would someone want to set up their own disposable mail server? In the context of software testing, while most of the time an online disposable email service is sufficient, on some occasions you might want to host a temporary email server on site:
- Some organizations block access to disposable emails, or even just unknown websites
- Some QA labs do not offer external Internet access
- Some products require multiple or controllable email domains tested
AHEM caters to all these needs and more.
To install AHEM, you’ll need a Linux or Windows machine with administrative rights and Node.js version 8.9+ as well as MongoDB installed.
Setting up Node.js, npm and MongoDB is out of the scope of this guide, but in case you’re lost, detailed information on how to set them up can be found on the Node.js download and MongoDB download pages.
The following section details the steps required to install and run AHEM disposable mail server. AHEM can run on any system supporting Node.js.
These steps were performed and tested on an Ubuntu Linux server and may need slight modifications to be compatible with other systems.
Install Angular CLI
AHEM uses Angular for its front end delivery, so you will need to globally install angular-cli:
npm install -g @angular/cli
npm install -g concurrently
Clone the AHEM GitHub Repository
git clone https://github.com/o4oren/ahem-server.git
Install Dependencies within the Created Folder
cd ahem-servernpm install
A configuration file named properties.json is located in the root of the project. Edit it to suit your preferences.
The properties.json file will look something like this:
Here is an explanation of the parameters within the properties file:
- serverBaseUri - the base address for your API server.
- mongoConnectUrl - the mongodb connect url.
- appListenPort - the port the node app binds to.
- smtpPort - the SMTP server’s port. Note that by default it is set to 2525 — this is done for testing purposes, as on many systems only a system account can listen on port 25. To receive standard SMTP email, change this to 25.
- emailDeleteInterval - The time in seconds between age checks for purging old emails.
- emailDeleteAge - The max age in seconds above which emails will be deleted.
- allowedDomains - An array of allowed email domains. These domains will be allowed by the server as RCPT TO: entries. This also makes the server not act as an open relay. Format: [“my.domain.com”, “my.second-domain.com”].
- customText - A html string that will replace the default text in the landing page.
- allowAutocomplete - If set to false, will prevent auto completing users in the UI.
Build the project
npm run build:ssr
This may take a while…
At this point, make sure your MongoDB server is up and running and that your properties.json file was configured correctly.
The easiest way to run AHEM, is run the project with the command:
Clap or star the GitHub Repo if you find this useful!