Email Testing Tip: Using One Email Account for Multiple Email Addresses
How to use email aliases to test multiple email accounts with only one account.
During software testing, we often need to verify and read emails, such as ‘Account Activation’, ‘Password Reset’, ‘Invoice’, …, etc. If possible, for internal testing, I would test emails in Automated Test Scripts with a Fake SMTP server: MailCatcher, as it is quick, safe, and easy to verify (using automated scripts). However, sometimes, using a Fake SMTP server is not possible (requires dev support and setup).
This article shares a tip on how to use the same email account and receive emails from ‘multiple email addresses’.
A typical use case is the ‘User Sign up’ test case.
A unique email address can only be used once for sign-up
I don’t want to create a new email account every time we test this scenario.
(‘User Sign up’ might be used often in test automation to create a unique user to prevent test data conflicts. Check out this article Case Study: User Change Password Automated Test)
A simple solution is adding a plus sign (+) and any word before the @ sign in one email account, e.g. testwisely+101@gmail.com, testwisely+102@gmail.com.
Doc: Create task-specific email addresses
Most apps will treat them as unique email addresses, but all emails will arrive at the same account, e.g. testwisely@gmail.com. This is known as email alias (one email address can have infinite aliases).
Here is a test. I sent two emails.
They arrived at the same Gmail account (testwisely@gmail.com).
Email details:
The email was sent to the aliased email (testwisely+102@gmail.com).
This alias trick should work for most email accounts, at least, Gmail and Outlook (I verified today).
Review By Zhimin
For manual email testing, sending actual emails to Gmail and Outlook are fine. But in test automation, we need to take into consideration of following efforts
Finding a specific email, and
Retrieving email content
using automation scripts.
Big email services such as Gmail usually add mechanisms to prevent automation (it may still be possible, but the mechanisms can change).
There are commercial email testing services (with free quotes)
https://mailtrap.io
https://testmail.app
And free online temporary mail services:
https://10minutemail.com
(no need to log in, but you may wait about 30 seconds or more for the email to come in, and there are advertisements on the page)
https://temp-mail.org
(no need to log in and no expiry for the email address, but there are advertisements)
Overall, I still recommend a Fake SMTP server: MailCatcher; It is easy, fast and reliable. You just need to convince the dev team, it only takes a minute or less to change the SMTP server setting for Dev and Test servers.
smtp_settings = { :address => “mail.server”, :port => 1025 }
Related reading: