DO NOT set the SSL.Destination
, SSL.Host
, or SSL.Port
properties manually! TIdTCPClient.Connect()
handles that for you. Besides, don't you think it's odd that you are setting SSL.Destination/Host
to smtp.gmail.com
but are setting SMTP.Host
to smtp.live.com
instead? Gmail and Live are not the same service provider.
Also, SSL.SSLOptions.Mode
should be set to sslmClient
instead of sslmUnassigned
. Not too important, TIdSSLIOHandlerSocketOpenSSL
will simply flip it when it configures the connection. But you should do it anyway, since you know your code is acting as a client.
And lastly, try setting SMTP.UseTLS
before setting SMTP.Port
, as setting UseTLS
may change the Port
, so you want to make sure you are really connecting to the correct port you are expecting.
With that said, the SSL Negotiation failed
error means the TLS handshake was started but failed part-way through the negotiation. Try assigning handlers to TIdSSLIOHandlerSocketOpenSSL
's OnStatusInfo/Ex
events to see how far the handshake is actually getting. And if you are using a relatively modern version of Indy 10, try looking at the raised exception's InnerException
property, it might give you a clue as to what went wrong before the EIdTLSClientTLSHandShakeFailed
exception was raised afterwards.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…