title: Connection Timeout when idSMTP when using TIdSSLIOHandlerSocketOpenSSL
body: <p>I'm having a problem using <strong>TidSMTP</strong> with <strong>TIdSSLIOHandlerSocketOpenSSL</strong> getting <strong>"Socket Error"</strong> just by connecting to the server.</p>
  
  <p>Here's the Form Component Code </p>
  
  <pre><code>  object IdSMTP: TIdSMTP
      IOHandler = IdSSLIOHandlerSSL
      Port = 465
      SASLMechanisms = &lt;&gt;
      UseTLS = utUseImplicitTLS
      Left = 93
      Top = 49
    end
    object IdSSLIOHandlerSSL: TIdSSLIOHandlerSocketOpenSSL
      OnStatus = IdSSLIOHandlerSSLStatus
      Destination = ':465'
      MaxLineAction = maException
      Port = 465
      DefaultPort = 0
      SSLOptions.Mode = sslmUnassigned
      SSLOptions.VerifyMode = []
      SSLOptions.VerifyDepth = 0
      OnStatusInfo = IdSSLIOHandlerSSLStatusInfo
      Left = 88
      Top = 112
    end
  </code></pre>
  
  <p>and Delphi Code</p>
  
  <pre><code> IdSMTP.Username  := 'username';
   IdSMTP.Password  := 'password';
   IdSMTP.Host      := 'domain';
   IdSMTP.Port      := 465;
   IdSMTP.UseTLS    := utUseImplicitTLS;
   try
      IdSMTP.Connect;
   except
      on E:Exception do
         // Socket Error, Connection Timeout is thrown.
         Memo1.Lines.Add(E.Message);
   end;
  </code></pre>
  
  <p>I logged SSL IO status and got this:</p>
  
  <pre><code>Resolving hostname {domain}.
  Connecting to {ip}.
  SSL status: "before/connect initialization"
  SSL status: "before/connect initialization"
  SSL status: "SSLv3 write client hello A"
  SSL status: "SSLv3 read server hello A"
  Socket Error # 10060
  Connection timed out.
  </code></pre>
  
  <p>Our mail server is using self-signed certificate by the way.</p>
  
  <p>What am i doing wrong?</p>
  
  <p>TIA</p>
  
  <p><strong>UPDATE:07-02-2014</strong></p>
  
  <p>Tried <a href="http://www.marcocantu.com/tips/oct06_gmail.html" rel="nofollow noreferrer">Sending mail to Gmail using Indy</a> tip but i get <strong>Connection Closed Gracefully</strong> sending the email also after <strong>SSLv3 read server hello A</strong>.</p>
  
  <pre><code>Resolving hostname smtp.gmail.com.
  Connecting to 74.125.25.108.
  Connected.
  Sending Email..
  SSL status: "before/connect initialization"
  SSL status: "before/connect initialization"
  SSL status: "SSLv3 write client hello A"
  SSL status: "SSLv3 read server hello A"
  Disconnected.
  Connection Closed Gracefully.
  </code></pre>
  
  <p>Here's the new code:</p>
  
  <pre><code> IdSMTP.Username  := 'username';
   IdSMTP.Password  := 'password';
   IdSMTP.Host      := 'smtp.gmail.com';
   IdSMTP.UseTLS    := utUseExplicitTLS;
   IdSMTP.Port      := 587;
   try
      // Can connect successfully
      IdSMTP.Connect;
  
      // This part throws the exception
      IdSMTP.Send(IdMessage);
   except
      on E:Exception do
         // Disconnected, connection closed gracefully 
         Memo1.Lines.Add(E.Message);
   end;
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Tried sending email using Thunderbird connecting to same domain. </p>
  
  <p>Thunderbird:
  <img src="https://i.stack.imgur.com/FmkgP.png" alt="Wireshark capture - Sending email using thunderbird"></p>
  
  <p>Indy:
  <img src="https://i.stack.imgur.com/tRI1M.png" alt="Wireshark capture - Using Indy"></p>
  
  <p>No "<strong>client key exchange, ...</strong>" occurred on my program.</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>This isssue was resolved by Manually setting connectiontimeout</p>