title: Error while sending mails using smtp
body: <p>I need to send mail from my gmail account to another. I used the following code.</p>
  
  <pre><code>               String fromaddress = "xxx@gmail.com"; 
      String password = "yyy";
      String hostname = "smtp.gmail.com";
      String hoststring = "mail.smtp.host";
      String toaddress = "yyy@gmail.com";
      String emailcontent;
  
      Properties properties = System.getProperties();
      properties.setProperty(hoststring, hostname);
      Session session = Session.getDefaultInstance(properties);
  
      try{
          MimeMessage message = new MimeMessage(session);
          message.setFrom(new InternetAddress(fromaddress));
          message.addRecipient(Message.RecipientType.TO, new InternetAddress(toaddress));
          message.setSubject("hi");
          emailcontent = "hi...";
          message.setText(emailcontent);
          System.out.println(emailcontent);
          Transport.send(message);
          System.out.println("Sent....");
      }catch (MessagingException mex) 
      {
          mex.printStackTrace();
      }
  </code></pre>
  
  <p>But i get the error as follows...
  javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25</p>
  
  <p>How am i to solve this. Can you please help me out.</p>