Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi XE Indy TIDSMTP and gmail : Socket Error 10060

Tags:

gmail

delphi

indy

I'm having this 'Socket Error 10060 - Connection timed out' when trying to send emails using TIDSMTP, on a Delphi XE application. The same code works on a Delphi 2007 application on the same machine. No firewalls or anti-virus software installed. Same DLLs used on both applications (libeay32.dll / ssleay32.dll).

Here is my code :

idsmtp1.host = 'xxxx'; 
idsmtp1.port = 465;
idsmtp1.username = 'x';
idsmtp1.password = 'x';
with ssl1 do
      begin
      SSLOptions.Method := sslvTLSv1;
      SSLOptions.VerifyMode := [];
      SSLOptions.VerifyDepth := 0;
      Destination := 'smtp.gmail.com:465';
      host := 'smtp.gmail.com';
      //OnStatusInfo := ssl1statusinfo;
      end;
idsmtp1.iohandler := ssl1;
idsmtp1.usetls := utUseImplicitTLS;
idsmtp1.UseEhlo := true;
idsmtp1.connect; // here the exception is throw 
like image 301
delphirules Avatar asked Jan 27 '26 14:01

delphirules


1 Answers

I don't know why, but adding some 'pause' in the event 'onStatusInfo' of TIdSSLIOHandlerSocketOpenSSL fixed the problem. Here is the code added :

procedure ssl1StatusInfo(Msg: string);
begin
sleep(500);
application.processmessages;
end;

Without this code i always got the 'Socket Error 10060 - Connection timed out'.

like image 183
delphirules Avatar answered Jan 31 '26 21:01

delphirules