How to send Mail using Java Mail API
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.
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.