I tried with Indy component to send email in XE2, and it works fine on my laptop that I compiled my project on.
But if I take my exe project to another PC, it shows an e
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.