title: Indy 9 SMTP Send with TLS causing crash
body: <p>I have a strange issue sending an email via gmail.
  I am using Delphi 7 and Indy 9 working on Windows 7 Professionel 32-bit on a VirtualBox (4.2)</p>
  
  <p>Since Indy 9 doesn't support TLS out of the box I have to send the  STARTTLS command myself.</p>
  
  <p>This works just well with a small test mail. A regular mail with an attachment causes the VirtualBox to completly crash. No Windows blue screen.</p>
  
  <p>I have already found a workaround but it seems quite dirty. If I add the IdSSLOpenSSL.pas from the Delphi source and add a Sleep(5); to the Send function it works</p>
  
  <pre><code>function TIdSSLIOHandlerSocket.Send(var ABuf; ALen: integer): integer;
  begin
    // 13.12.2012 fix timing
    Sleep(5);
  
    if fPassThrough then begin
      result := inherited Send(ABuf, ALen);
    end
    else begin
      result := SendEnc(ABuf, ALen);
    end;
  end;
  </code></pre>
  
  <p><strong>Is there a better way to fix this issue?</strong></p>
  
  <p>In case you need the Code to setup the IOHandler</p>
  
  <pre><code>sslIOHandler                   := TIdSSLIOHandlerSocket.Create(nil);
  sslIOHandler.SSLOptions.Method := sslvTLSv1;
  sslIOHandler.PassThrough       := True;
  IdSSLOpenSSLHeaders.Load;
  smtpClient.Username            := tbUsername.Text;
  smtpClient.Password            := tbPassword.Text;
  smtpClient.AuthenticationType  := atLogin;
  smtpClient.IOHandler           := sslIOHandler;
  smtpClient.Connect(C_TIMEOUT);
  smtpClient.SendCmd('STARTTLS');
  sslIOHandler.PassThrough := False;
  smtpClient.Authenticate();
  </code></pre>