Nov 17, 2018
AHEM — Ad Hoc 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.
AHEM - Ad Hoc Email is one of these services. You can send an email to an @ahem.email address and check the AHEM mailbox to retrieve and read the email. Many similar services such as Mailinator, ThrowAwayMail, Temp-Mail and Yopmail are available online to name a few.
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:
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.
npm install -g @angular/cli
npm install -g concurrently
git clone https://github.com/o4oren/ahem-server.git
cd ahem-server npm install
The .env file should look like this:
serverBaseUri=http://localhost:3000 mongoConnectUrl=mongodb://localhost:27017/ dbName=ahem appListenPort=3000 smtpPort=2525 emailDeleteInterval=3600 emailDeleteAge=86400 allowAutocomplete=true allowedDomains=my.domain.com jwtSecret=AH3M 709 S3cR3T jwtExpiresIn=3600 maxAllowedApiCalls=1000
Here is an explanation of the parameters within the properties file: serverBaseUri - the base address for your API server. mongoConnectUrl - the mongodb connect url. Example: “mongodb://localhost:27017/ahem”. 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.
npm run build:ssrThis 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:
node ahem.jsThis command will start (by default) the backend server on port 3000 and the front end will run on port 4200. You can then access the AHEM web interface at http://localhost:4200.