我的问题是,当我使用Indy使用Gmail发送电子邮件时,它可以在安装了RAD Studio的计算机上正常工作。但是,当我将我的发布版本复制到安装了Windows 10的不同计算机时,它会出现“SSL协商失败”错误
我的代码是:
lIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
lIOHandler.SSLOptions.Method := sslvTLSv1;
lIOHandler.SSLOptions.Mode := sslmClient;
strA := EditOsoite.Text;
charArray[0] := ';';
o := 0;
IdSMTP1.IOHandler := lIOHandler;
IdSMTP1.UseTLS := utUseRequireTLS;
IdSMTP1.Host := 'smtp.gmail.com'; // EditPalvelin.Text;
//IdSMTP1.Authenticate;
// IdSMTP1.UseTLS := utUseExplicitTLS;
IdSMTP1.Username := EditPalvelin.Text;
IdSMTP1.Password := EditSalasana.Text;
IdSMTP1.Port := 587;
try
try
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
IdMessage1.Clear;
Sleep(1000);
//IdMessage1.Free;
except on E:Exception do begin
ShowMessage('Virhe lähetettäessä');
ShowMessage('There was an error: ' + E.Message);
//StatusMemo.Lines.Insert(0, 'ERROR: ' + E.Message) ;
end;
end;
finally
if IdSMTP1.Connected then begin
IdSMTP1.Disconnect;
//IdSMTP1.Free;
//IdMessage1.Free;
end;
end;