Reputation: 1002
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)
Since Indy 9 doesn't support TLS out of the box I have to send the STARTTLS command myself.
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.
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
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;
Is there a better way to fix this issue?
In case you need the Code to setup the IOHandler
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();
Upvotes: 2
Views: 3873
Reputation: 1002
Since noone seems to have a solution for this and upgrading to Indy 10 is no option (too many projects are involved) I found a different library to handle smtp with tls...
Now I use Synapse which does not interfere with Indy 9 and does just what I expected.
http://synapse.ararat.cz/doku.php/public:howto:smtpsend
Hopefully this helps others with the same problem.
Upvotes: 1