archie.herbias -2 Newbie Poster

is it possible not to include the account password for the user that will send the email. i tried not to put password but it does not work. the email that can send only is the one that is set. please help. this is the code:

<%@ page import="*,java.util.*,javax.mail.*"%>
<%@ page import="javax.mail.internet.*,javax.activation.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>


    String host="", user="", pass="";
    host = ""; //"";
    user = "email";  // email id to send the emails
    pass = "password"; //Your gmail password
    String SSL_FACTORY = "";
    String to = request.getParameter("to");// out going email id
    String from = user;// Email id of the sender/server
    String subject = "subject";
    String messageText = request.getParameter("body");
    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);
    out.println("mailSession : " + mailSession);
        Message msg = new MimeMessage(mailSession);
        msg.setFrom(new InternetAddress(from));
        InternetAddress[] address = {new InternetAddress(to)};
        msg.setRecipients(Message.RecipientType.TO, address);
        msg.setContent(messageText, "text/html"); // use setText if you want to send text
        Transport transport = mailSession.getTransport("smtp");
        transport.connect(host, user, pass);
            transport.sendMessage(msg, msg.getAllRecipients());
            out.println("Email sent");
        catch (Exception err)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.