title: Java Mail Exception Error;
body: <p>MyCode:</p>
  
  <pre><code>import java.util.Properties;
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.PasswordAuthentication;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  public class SendMailTLS {
  public static void main(String[] args) {
      final String username = "myemailid@gmail.com";
      final String password = "myemailpassword";
      Properties props = new Properties();
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.starttls.enable", "true");
      props.put("mail.smtp.host", "smtp.gmail.com");
      props.put("mail.smtp.port", "587");
      Session session = Session.getInstance(props,
        new javax.mail.Authenticator() {
          protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(username, password);
          }
        });
  
      try {
          Message message = new MimeMessage(session);
          message.setFrom(new InternetAddress("myemailid@gmail.com"));
          message.setRecipients(Message.RecipientType.TO,
              InternetAddress.parse("myfriedemail@ymail.com"));
          message.setSubject("Testing Subject");
          message.setText("Dear Mail Crawler,"+
   "\n\n No spam to my email,please!"); 
          Transport.send(message);
          System.out.println("Done");
      } catch (MessagingException e) {
          throw new RuntimeException(e);
      }
  }
  }
  </code></pre>
  
  <p>My Error:</p>
  
  <blockquote>
    <blockquote>
      <p>Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: <br>Unknown SMTP host: smtp.gmail.com;<br>
        nested exception is:<br>
          java.net.UnknownHostException: smtp.gmail.com<br>
          at Mail.SendMailTLS.main(SendMailTLS.java:56)<br>
      Caused by: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;<br>
        nested exception is:<br>
          java.net.UnknownHostException: smtp.gmail.com<br>
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1970)<br>
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)<br>
          at javax.mail.Service.connect(Service.java:317)<br>
          at javax.mail.Service.connect(Service.java:176)<br>
          at javax.mail.Service.connect(Service.java:125)<br>
          at javax.mail.Transport.send0(Transport.java:194)<br>
          at javax.mail.Transport.send(Transport.java:124)<br>
          at Mail.SendMailTLS.main(SendMailTLS.java:51)<br>
      Caused by: java.net.UnknownHostException: smtp.gmail.com<br>
          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)<br>
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)<br>
          at java.net.Socket.connect(Socket.java:525)<br>
          at java.net.Socket.connect(Socket.java:475)<br>
          at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)<br>
          at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)<br>
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)<br>
          ... 7 more<br>
      Java Result: 1<br></p>
    </blockquote>
  </blockquote>
  
  <p><strong>I am having the Local proxy as 172.17.0.4:8080</strong>
  with username as :<strong>user1</strong>, password as: <strong>user2</strong> <Br> Solutions pls??</p>