Transport.send(msg) not working
<p>I am trying to send an email from one account to another using javamail. But the code is unable to execute Transport.send(msg); line. What could be the possible reason?
Below is the following jsp code.</p>

<pre><code>&lt;%

        String host = "localhost";
        String to = request.getParameter("to");
        String from = request.getParameter("from");
        String subject = request.getParameter("subject");
        String messageText = request.getParameter("body");
        boolean sessionDebug = false;

        Properties props = System.getProperties();
        props.put("mail.host", host);
        props.put("mail.transport.protocol", "smtp");

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

        mailSession.setDebug(sessionDebug);

        try { 
        Message msg = new MimeMessage(mailSession);

        msg.setFrom(new InternetAddress(from));
        InternetAddress[] address = {new InternetAddress(to)};
        msg.setRecipients(Message.RecipientType.TO, address);
        msg.setSubject(subject);
        msg.setSentDate(new Date());
        msg.setText(messageText);

        Transport.send(msg);

        out.println("Mail was sent to " + to);
        out.println(" from " + from);
        out.println(" using host " + host + ".");
        } catch (MessagingException mex) {mex.printStackTrace();}
    %&gt;
</code></pre>