step1- Add the external JAR file to your library step2- modify the code according to your mail id and sender mail step3- make your gmail account less secure by singing into the account which you will be using in the code https://myaccount.google.com/lesssecureapps