Send Email using Core Java

To send email using core java first of all you required JavaMail API in your computer. You can download lates version of JavaMail API.

Download and extract files from javamail-version.zip file. Here you will find mail.jar file. For successfully run below example you need to set CLASSPATH to this jar file.

Send Email using Core Java Sample Code

Step 1 : Compile SendMail.java file

javac -cp “Path to mail.jar file” SendMail.java

Step 2 : Run SendMail with Java

java -cp “Path to SendMail.java;Path to mail.jar file” SendMail