Ways to automate e-mail validation

    In our application, every-time when user orders a product we would sent out order-confirmation mail to user inbox and body of the mail contains order-reference number, product details - name,quantity and etc.  We usually validate this manually through disposable emails (mailinator.com)  but every-time when there's a change in structure/content of order-confirmation mail we need to repeat this process for each product in our application which became more and more time-consuming. So if you guys could suggest tools or ways to automate this process, I would love hear it.

Use a Gmail account and Selenium to automatically confirm cookies, log in, open the mailbox, open the relevant message and validate the content?

1 Like

Hi and welcome to the MoT Community! :slight_smile:

You can do this by making an SMTP request to your mailbox, it’s like a REST API but for mails.


Hi @reid_richards , I believe the easiest way to do it is to use testRigor. It runs the service similar to mailinator under the hood, and on top of it once you check the email it would render it for you in the browser so you can use regular validations like you can for a page. Here is the documentation: testRigor Documentation - Intelligent Test Automation Tool [2022] - testRigor Software Testing
And here is how your test code would look like (literally):

generate unique email, then enter into "Email" and save as "newEmail" 
click "Place order"
grab value from text below "Order Number" and save it as "orderNumber"
check that email to stored value "newEmail" was delivered // This renders the email
check that page contains stored value "orderNumber"
check that page contains "My product name"
check that page contains "5" on the right of "Quantity"

testRigor is free for open source (making your tests and test data open source) or have a free trial for commercial applications. Here is a video of how to use email: How to test a sign-up flow with email - YouTube . Happy to show you a demo if you’d like.

1 Like


using MailHog could help. You can test email send/receive locally and if you want to use it in test automation tools, you could use the API for getting the stuff.


1 Like

Hi Reid. And welcome to the most awesome Testing Community in the Milky Way.

I would be very wary of testing that “email gets sent”, that’s a 3rd party integration. You really want to test this in the app or service layer if possible. It’s faster, and removes the problem of a test that uses a hard coded mailbox becomes a non-reentrant test, if 2 engineers run the same test at once and the mailbox has not been emptied. So look out for race conditions. Always be sure to be testing the right thing, at the right layer where it matters.

Testing every single product code gets sent via an SMTP is pointless, you end up that execution time in testing is mainly in the 3rd party code, not the code that formats or parses emails. so you get great confidence that Mailhog works, but not much about your product’s email parser.


We all encounter a situation in some point of time when we need more than UI Testing or performance testing services from selenium.
In our project, we have verified the email with a Gmail account.
The programming language we use is java and have used javax.mail library.
With this library you can create connection to your Gmail, get all mail’s subject lines as well as their content.
You can also delete emails along with several other features.

Hope it helps.
Good Luck.