Simple E-Mail Program From Gmail Using JSP in TGMC

Email :
It is used to send the plain text message from the application which you have developed.
This Program allow us to add the Subject ,Message in addition to that it gets Sender id and password to authenticate and also gets Receiver Email id.
Here we gave a sample code for Gmail SMTP Server.not for all.You can Reach other SMTP server codes in other snippets.

//Simple Email Program 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
    language="java" contentType="text/html; charset=ISO-8859-1"
<title>Simple Mail Program</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@page import="java.sql.*"%>
<%@page import="javax.mail.*"%>

<%@page import="javax.mail.internet.*"%>
<%@ page import="*"%>
<%@ page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@ page import="java.math.BigInteger"%>

    String host = "";

    //host = smtp_server; //""; user = jsp_email; //"" // email id to send the emails

    //pass = jsp_email_pw; //Your gmail password

    String SSL_FACTORY = "";
    String to_add = "yyy", subject = "Mail Test", messageText = "Welcome To Forget Code", password = "xxxx";

    String from = "zzzzzz";

    boolean sessionDebug = true;

    Properties props = System.getProperties();

    props.put("", host);

    props.put("mail.transport.protocol.", "smtp");

    props.put("mail.smtp.auth", "true");

    props.put("mail.smtp.", "true");

    props.put("mail.smtp.port", "465");

    props.put("mail.smtp.socketFactory.fallback", "false");

    props.put("mail.smtp.socketFactory.class", SSL_FACTORY);

    Session mailSession = Session.getDefaultInstance(props, null);


    Message msg = new MimeMessage(mailSession);

    msg.setFrom(new InternetAddress(from));

    InternetAddress[] address = { new InternetAddress(to_add) };

    msg.setRecipients(Message.RecipientType.TO, address);


    msg.setContent(messageText, "text/html"); // use setText if you want to send text

    Transport transport = mailSession.getTransport("smtp");
    System.setProperty("", "conf/jssecacerts");
    System.setProperty("", "admin");
    transport.connect(host, "sender_mail_id", "password_of_sender");

    try {

        transport.sendMessage(msg, msg.getAllRecipients());
        //WasEmailSent = true; // assume it was sent


    catch (Exception err) {

        //WasEmailSent = false; // assume it's a fail

        out.println("Error" + err.getMessage());