Posts

Showing posts with the label send mail from core java

Send a mail through core java by using Gmail authentication

Image
In the current post, I am trying to explain how to send a mail through the core java program by using Gmail authentication. The below mentioned only one core program which will contain the source code of mail sender. In the below source you have to place your Gmail username, password and from address and to address.   As we know mail.jar is not present in J2SE, we have to download externally and place it into CLASSPATH. Along with mail.jar download the below list of jars and add it into CLASSPATH to avoid compilation error. dsn-1.5.5.jar gimap-1.5.5.jar imap-1.5.5.jar javax.mail.jar javax.mail-api-1.5.5.jar logging-mailhandler-1.5.5.jar mailapi-1.5.5.jar pop3-1.5.5.jar smtp-1.5.5.jar GoogleMail.java import java.util.Properties ; import javax.mail.Message ; import javax.mail.MessagingException ; import javax.mail.PasswordAuthentication ; import javax.mail.Session ; import javax.mail.Transport ; import javax.mail.internet.InternetAddress ;