Must issue a STARTTLS command first
<p>I am running this simple example ,with my Gmail account , but its not working and giving error</p>

<pre><code>      send failed, exception: com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first. nv2sm4478384pbb.6      
</code></pre>

<p>hers is my code</p>

<pre><code>   public class Email
{
   public static void main(String [] args)
   {

       Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.googlemail.com");
        props.put("mail.from", "myemail@gmail.com");
          Session session = Session.getInstance(props, null);

        try {
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom();
            msg.setRecipients(Message.RecipientType.TO,
                              "myemail@hotmail.com");
            msg.setSubject("JavaMail hello world example");
            msg.setSentDate(new Date());
            msg.setText("Hello, world!\n");
            Transport.send(msg);
        } catch (MessagingException mex) {
            System.out.println("send failed, exception: " + mex);
        }
   }
}
</code></pre>
