JMeter provides various options to handle email related scenarios in load testing activities. We already saw how we can send an email using JMeter in earlier post. This post now covers JMeter Mail Reader Sampler which can be used to receive emails from JMeter. This mail reading feature helps in number of scenarios like email verification, email confirmation etc.
We will use Mail Reader Sampler of JMeter to read an email. JavaMail API is needed to enable email functionality in JMeter. Download it from here and paste the JAR in JMeter’s lib folder. Now, perform below steps to configure JMeter Mail Reader Sampler.
- Add a new Thread Group under Test Plan.
- Right click on Thread Group and select Add–>Sampler–>Mail Reader Sampler. Once added, we need to provide IMAP/POP3 server details in sampler.
- We will use GMail’s IMAP protocol for receiving an email in JMeter. Therefore, set Protocol value to ‘imaps’. Similarly enter ‘imap.googlemail.com’ and ‘993’ as server host and port values respectively.
- Provide valid user name and password values.
- We can also specify number mails we want to receive.
- As GMail requires SSL, select ‘Use SSL’ radio button in Security Settings section.
- After performing all above steps, your Mail Reader Sampler should be displayed as below image.
- Run your test!
Below are other notable options present in Mail Reader Sampler.
- Folder – a folder in email account.
- Delete messages from the server – specify whether JMeter should remove messages from the server after retrieval.
- Store the message using MIME – specify whether the entire message will be stored in the Response Data.
After performing above simple steps, you should be able to configure your JMeter to read emails. To view the result, add a ‘View Result Tree’ listener under the Thread Group where you could read your emails.