How to send Mail using Java Mail API

Tatarao voleti
Spring eco system
Published in
1 min readNov 27, 2018

In this tutorial we are going to explore, how to send email using java Api.

By using java mail API we can send e-mails to any valid recipient. In this article we are going to use Gmail SMTP to send mails.

So we need configure gmail username and password in java application.

In order to make use of this application it is required to add mail.jar in class-path of your application.

Since Gmail is so secured , we cannot easily send emails using java with Gmail credentials.

Photo by Michael Mroczek on Unsplash

To make use of Gmail SMTP, first we need to allow untrusted applications access in Gmail settings. Otherwise Gmail won’t allow our java program to make use of it’s SMTP server.

Email using java mail api with support of GMail SMTP Server

--

--

Tatarao voleti
Spring eco system

Software Developer @Siemens | Spring Boot, Micro Services, AWS Cloud | Tech blogger