How to read Emails using JMeter

|
| By Webner

JMeter is an open-source tool that helps to perform load testing. It provides various samplers to perform load testing. Today, we will discuss email related samplers. There are two samplers to perform an action related to the email, read(mail reader sampler) and send(SMTP) email. With the help of these samplers, we can execute email related test cases in load testing activities.

Steps to read emails:

  1. Initially, Configure the Javamail in the JMeter.
    Download JavaMail(javax.mail.jar) from this link:
    https://javaee.github.io/javamail/“.
    Put the JavaMail jar into the JMeter ‘lib folder’ and restart it.
    Location to add file : C:\apache-jmeter-5.4\lib
  2. Create a Test plan and Add a Thread Group.
  3. Add mail reader sampler:
    Thread Group->Add->Sampler->mail reader sampler
  4. Once the mail reader sampler added, we need to add data into it:
    • Here, we need the Gmail protocol to read the email from Gmail in JMeter. To get email protocol, access this link Gmail Protocol. We will use the Gmail IMAP protocol for receiving an email in JMeter. Therefore, set the Protocol value to ‘imaps’. Similarly, enter ‘imap.googlemail.com’ and ‘993’ as ‘server host’ and ‘port’ values respectively.
    • Enter a valid username(email address) and password.
    • Specify the number of emails.
    • Select “Use SSL” from the ‘security setting’ as Gmail requires an SSL certificate.

    Screenshot:

    jmeter

    Other options available in the mail reader sampler:
    Folder: A folder in an 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.

  5. Finally, Add a listener to see the result and Run the script. Here, we are using the ‘Result tree’ listener.

    Thread Group->Add->Listener->View Results Tree

    jmeter1

Configuration setting in Gmail account to access in the JMeter:

To access Gmail in the JMeter, we need to do some configuration settings in the Gmail account. Without these changes, It throws authentication errors every time.

  1. Enable the IMAP from the Gmail account.
    gmail
  2. Turn on less secure app access.
    Security-> less secure app access

Leave a Reply

Your email address will not be published. Required fields are marked *