title: javax.mail.MessagingException: Could not connect to SMTP host in Android while sending a Java mail with attachement
body: <p>I am trying to send the attachment over the mail using smtp server( personal mail, not gmail).
  Now while sending it is not reaching to the destination and giving 
  javax.mail.MessagingException</p>
  
  <p>Here is the full error which i am getting:</p>
  
  <pre><code>    In exception while sending mail****************************** javax.mail.MessagingException: Could not connect to SMTP host: mail.theftsecurity.net, port: 25;
  04-27 13:26:38.933: D/Testing(17074):   nested exception is:
  04-27 13:26:38.933: D/Testing(17074):   java.net.SocketTimeoutException: failed to connect to mail.theftsecurity.net/203.124.98.72 (port 25) after 90000ms
  04-27 13:26:38.934: D/Testing(17074): From Async send mail:Exception Message:Could not connect to SMTP host: mail.theftsecurity.net, port: 25
  04-27 13:26:38.934: D/Testing(17074): From Async send mail:Exception local Message:Could not connect to SMTP host: mail.theftsecurity.net, port: 25
  04-27 13:26:38.935: D/Testing(17074): From Async send mail:Exception trace:[Ljava.lang.StackTraceElement;@42592a50
  04-27 13:26:38.935: D/Testing(17074): From Async send mail:Exception Cause:java.net.SocketTimeoutException: failed to connect to mail.theftsecurity.net/203.124.98.72 (port 25) after 90000ms
  </code></pre>
  
  <p>In my code i have used this parameters to send the mail and i think some of them is causing the issue, but exactly don't know what is that basically:</p>
  
  <pre><code>Properties props = new Properties();
  
      props.put("mail.smtp.host", _host);
  
      if (_debuggable) {
          props.put("mail.debug", "true");
      }
  
      if (_auth) {
          props.put("mail.smtp.auth", "true");
      }
  
      props.put("mail.smtp.port", "25");
       if(_host.contains("gmail")||_host.contains("yahoo")){
             props.put("mail.smtp.socketFactory.port", "465"); 
             props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
           }
      props.put("mail.smtp.socketFactory.fallback", "false");
      props.put("mail.smtp.starttls.enable", "true");
  </code></pre>
  
  <p>Now, what i observed is, when i am using gmail, it is working fine. And i have tested the smtp in the below website</p>
  
  <p><a href="http://smtper.nanogenesis.fr/" rel="nofollow">http://smtper.nanogenesis.fr/</a></p>
  
  <p>And it is sending the mail to my desired mail id.
  So can any one please tell where is the issue exactly..</p>
  
  <p>Thanks,
  Arindam.</p>