How to send Google mail in Apache JMeter?

In this article, you are going to learn how to send google mail in Apache JMeter. You may ask, what is the necessity of sending emails in JMeter. When I working for a gig, there was a requirement to trigger emails when the response contains the error message. The client wants to trigger emails to his google mail box. Now we will see how to accomplish it in JMeter.

Send Google mail in Apache JMeter

JMeter has a vast variety of samplers which makes us expedite the process of scripting. To send emails using SMTP/SMTPS protocol, JMeter has SMTP sampler. To add SMTP sampler, right click on appropriate item in your test plan > Add > Sampler > SMTP Sampler.

SMTP sampler has various settings which will trigger emails in a secured connection. Below is the snapshot which will send emails to Google mail.

Following settings are valid in JMeter which will trigger the email to Google mail.

SMTP Sampler send google mail in apache jmeter
SMTP Sampler
  1. Server:
  2. Port: 587
  3. Address From/To: Valid Gmail ID
  4. Auth: Valid username and password
  5. Select Use StartTLS under Security Settings
  6. Enter valid Subject Line and Message

Save your test plan and execute it. You will get errors in your listener. All you need to do is add below code in your jmeter.bat file. Please take a backup before you make any changes to bat file.

  1. Open your jmeter.bat in your favorite editor (I prefer notepad++)
  2. Find below string

set ARGS=

  1. Replace it with below string


  1. Before the above line add set
  2. It should like as shown below



Save the test plan and execute the script. You will get an error again. This time, you need to change the settings to your Google mail account.

Google Mail Settings

Go to and turn on Access for less secure apps. 

Less Secure Apps
Less Secure Apps

Please note that if you enabled two-step authentication in your Gmail account, then you may need to disable it.

Less Secure Apps Error
Less Secure Apps Error

Now go back to your JMeter script, and execute the script. Emails will be triggered to your Google mail. Make sure that you have added appropriate Regular Express Extractor and If Controller samplers.

Regular Express Extractor enables you to extract the response and If Controller runs only if the condition satisfies i.e. if any error message occurs it triggers the SMTP sampler as shown below.

JMeter Sampler
JMeter Sampler

I hope above tutorial on how to send Google mail in Apache JMeter helped you and you learnt few tricks. Please share this article with your friends. Sharing is caring.

How to send Google mail in Apache JMeter

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Learn Apache JMeter for free. No Strings Attached.Watch Now for FREE
+ +
Share via
Copy link