Indy 10 - IdSMTP.Send () freezes when sending messages from GMail account

I am trying to send an email using a gmail account (Delphi 7, Indy 10) with these settings:

TIdSmtp:

Port = 587; UseTLS := utUseExplicitTLS; 

TIdSSLIOHandlerSocketOpenSSL:

 SSLOptions.Method := sslvTLSv1; 

Everything seems to be set up fine. I get this answer:

 Resolving hostname smtp.gmail.com. Connecting to 74.125.77.109. SSL status: "before/connect initialization" SSL status: "before/connect initialization" SSL status: "SSLv3 write client hello A" SSL status: "SSLv3 read server hello A" SSL status: "SSLv3 read server certificate A" SSL status: "SSLv3 read server done A" SSL status: "SSLv3 write client key exchange A" SSL status: "SSLv3 write change cipher spec A" SSL status: "SSLv3 write finished A" SSL status: "SSLv3 flush data" SSL status: "SSLv3 read finished A" SSL status: "SSL negotiation finished successfully" SSL status: "SSL negotiation finished successfully" Cipher: name = RC4-MD5; description = RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5 ; bits = 128; version = TLSv1/SSLv3; 

And then it hangs and does not end. Email is not sent. What could be the problem?

+6
delphi smtp gmail delphi-7 indy
source share
4 answers

The problem was simple. I was not patient enough, and the application did not freeze, there was a long timeout. The timeout was the result of incorrect settings.

+3
source share

Yes, I saw a lot of problems with indy10 and tls (usually gmail).

first make sure you have the latest ssl libraries from here

I saw intermittent kiosks and bugs that were resolved in the version with indy convex paint (i.e. unstable version). see http://www.indyproject.org/sockets/download/svn.DE.aspx

for gmail, I usually use implicityTLS on port 465.

  idSmtp := TIdSMTP.Create(nil); try idSmtp.IOHandler := nil; idSmtp.ManagedIOHandler := true; // try to use SSL try TIdSSLContext.Create.Free; idSmtp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(idSmtp); if (smtpSettings.port = 465) then idSmtp.UseTLS := utUseImplicitTLS else idSmtp.UseTLS := utUseExplicitTLS; except idSmtp.IOHandler.Free; idSmtp.IOHandler := nil; end; if (idSmtp.IOHandler = nil) then begin idSmtp.IOHandler := TIdIOHandler.MakeDefaultIOHandler(idSmtp); idSmtp.UseTLS := utNoTLSSupport; end; // send message, etc finally idSmtp.Free; end; 
+4
source share

First, did you confirm that the code works with other email servers?

Some time ago, someone said that they were having problems with some servers that accept HTTP requests with the Indy TIdHTTP component. The reason was because Indy included it as part of the user agent:

  Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)'; 

When they removed the Indy Library , it worked. Obviously, some malignant web services have appeared with Indy, so some sites will refuse to connect from applications created with it.

I am not sure if the component you are using has any UserAgent property. But if so, exclude any references to Indy.

+1
source share

When testing Indy, you must be sure that the "Stop on Delphi exceptions" checkbox is selected ("Tools", "Debugger Settings", "Language Exceptions").

Some procedures, in particular idSMTP.Send, 'eat (or hide) exceptions that lead to a hang.

+1
source share

All Articles