Read Mails using JMeter Mail Reader Sampler
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.
Nice.Neat. Thanks Maharshi 🙂
Thank you for the great explanation. I have only one question > The test is reading the first mail in my inbox. If I want to read the last inboxed mail. What should I do?
Yes I have same issue. Any luck>
Even, I am also not able to read the latest mail, how to achieve this?
Hi,
I am getting Response code: 500 and not able to retrieve mail.
turn on less security app in your mail
i am getting following error java.lang.NoClassDefFoundError: javax/activation/DataSource
getting the same error – java.lang.NoClassDefFoundError: javax/activation/DataSource
I am getting below error:
Response code: 500
Response message: javax.mail.MessagingException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target;
nested exception is:
When i am trying to read my emails from sent folder i am getting 500 response code in o/p. how we can solve this issue?