title: Java error javax.mail.MessagingException: Could not connect to SMTP host:
body: <p>I have a java application which sends email.It have been working well never had this problem. Suddenly today I see a lot of these error, but there are some which went through successfully.Below is the full trace.</p>
  
  <pre><code>javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465;
  nested exception is:
  java.net.ConnectException: Connection timed out
  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
  at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
  javax.mail.Service.connect(Service.java:317)
  at javax.mail.Service.connect(Service.java:176)
  at javax.mail.Service.connect(Service.java:125)
  at javax.mail.Transport.send0(Transport.java:194)
  at javax.mail.Transport.send(Transport.java:124)
  at commServer9000$MailProcessor.run(commServer9000.java:6550)
  at java.lang.Thread.run(Thread.java:619)
  Caused by: java.net.ConnectException: Connection timed out
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
  at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
  at java.net.Socket.connect(Socket.java:529)
  at java.net.Socket.connect(Socket.java:478)
  at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
  at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
      ... 8 more
  </code></pre>