title: Could not connect to SMTP host: smtp.yahoo.com, port: 25
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7158951/javax-mail-messagingexception-could-not-connect-to-smtp-host-smtp-gmail-com-p">javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 25;</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to implement mailing facility in my code but I am getting this exception. Please suggest some solution. I am doing it in intellij idea.</p>
  
  <pre><code>javax.mail.MessagingException: Could not connect to SMTP host: smtp.yahoo.com, port: 25;
  nested exception is:
  java.net.ConnectException: Connection timed out: connect
  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)
  at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
  at javax.mail.Service.connect(Service.java:295)
  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 SendMail.send(SendMail.java:53)
  at SendMailTest.main(SendMailTest.java:11)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
  Caused by: java.net.ConnectException: Connection timed out: connect
  at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
  at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
  at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
  at java.net.Socket.connect(Socket.java:579)
  at java.net.Socket.connect(Socket.java:528)
  at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
  at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:233)
  at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)
  ... 13 more
  </code></pre>