Email Sending Program using Gmail Servers. in Java

A Simple program using java mail API that sends mail.
Note. You must have javax,mail package. To get it download Java EE SDK from

Add the modules folder to your class path before complie.

Note: A Working Internet Connection is must to send mail.

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;
import javax.mail.internet.MimeMessage;
public class SendMailSSL {

    public static void main(String[] args) {
               String myaddr="";
                 String mypass="your_mail_password";
                 String destaddr="destination Addr ";
    Properties props = new Properties();
              props.put("", "");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
        Session session = Session.getDefaultInstance(props,
            new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(myaddr,mypass);
        try {
                                          String msgtext="This is the mail from Java Program";
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(""));
            message.setSubject("Mail Using Java Program. Reply Me ");
        } catch (MessagingException e) {
            throw new RuntimeException(e);