Testing Emails in Automated Test Scripts with a Fake SMTP server: MailCatcher

Safe, Fast, and Reliable Email Testing with Selenium WebDriver and MailCatcher

Zhimin Zhan
5 min readMay 26, 2021

--

This article is included in my “How to in Selenium WebDriver” series.

On a recent software project, I heard of an embarrassing mistake: emails have been sent to real customers during internal system testing.

CUSTOMERS SHALL NEVER RECEIVE TESTING EMAILS!

Unfortunately, this could happen to software testing after certain production data was loaded for verifying production issues when lacking good prevention procedures.

To avoid this, I have seen many solutions have been used, such as:

  • Disable emails sending
  • Replace all account emails with a fixed test email address
  • An improved version of the above by including the recipient testuser+realusername@gmail.com

However, all of the above were complex and inadequate. My favorite (and the simplest) solution is to use a fake SMTP server, such as MailCatcher. I have been testing emails this way for over 10 years, never had any problems. There are some alternative commercial email testing servers/services on the market, such as MailTrap (recommend

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.