How to send an email after executing a test in JMeter 🤔 ?

Sukhwinder Singh
3 min readDec 24, 2023

--

There are different methods to send JMeter reports via email. In this story, I will discuss the steps to send reports using SMTP Sampler.

đź“ŁTakeaway

  • 👉Sent email after JMeter test execution
  • 👉Attach test reports via email

Prerequisite

  • 👉Basic understanding of Jmeter scripting

👉Note: I used Gmail account for explanation purposes. For organization email, contact your IT support team for required details.

A. Steps to follow to setup SMTP Sampler

1. Add SMTP Sampler in your Jmeter Script (In my case, I have added it in tearDown thread Group)

2. Set the “Server Name ” field to the SMTP server’s address as I have used Gmail account I have added “smtp.googlemail.com”

3. Set the “Port” field to the SMTP server’s port number (in my case for gmail account it’s 587).

4. Set the “From” field to the sender’s email address.

5. Set the “To” field to the recipient’s email address.

6. Set the “Subject” field to the subject of the email

7. Set the “Message” field to the body of the email

8. Attach ”location of your test results”

B. Setting up Google email account

1. 2-Step Verification must turned on. Go to security and make the changes.

2. Please note : Google stopped supporting “Less Secure Apps” as of May 30th, 2022. Therefore click on the “2-Step Verification” , go down to the end of the list and click on “App passwords”.

3. Generate a password and add the same password in SMTP sampler

C. How do you attach reports in an email?

Just add the result location in the view result tree as shown in the example below. Please note I have used ${__time(dd-MM-yyyy) to append the date and time for my test result.

“F:\TestResults_${__time(dd-MM-yyyy)}.csv”

Configuration is now finished; execute the script.

Hurray 🥳, it works as shown in the below snapshot.

Sample script file for reference 🙂

--

--

Sukhwinder Singh

Experienced and highly skilled Quality Assurance (QA) Engineer with a passion for software testing and ensuring high-quality product releases.