我使用的是Delphi XE和Indy版本10.5.7,试图使用Amazon SES发送电子邮件,但我总是遇到以下异常:
First chance exception at $76734E28. Exception class EIdSocketError with message
'Socket Error # 10060
Connection timed out.'.
Process sendtest.exe (4472)
First chance exception at $76734E28. Exception class EIdException with message 'Reply Code is not valid: p'. Process sendtest.exe (4472)
我在下面使用的相同代码可在Delphi 2007和Indy版本10.6.1.5188上的应用程序中使用:
idsmtp1.Host := 'email-smtp.us-west-2.amazonaws.com';
idsmtp1.username := 'myusername';
idsmtp1.password := 'mypassword';
idsmtp1.Port := 587;
idsmtp1.IOHandler := IdServerIOHandlerSSLOpenSSL1;
idsmtp1.usetls := utUseExplicitTLS;
idsmtp1.UseEhlo := true;
with IdServerIOHandlerSSLOpenSSL1 do
begin
SSLOptions.Method := sslvTLSv1;
SSLOptions.VerifyMode := [];
SSLOptions.VerifyDepth := 0;
end;
idsmtp1.Connect;
idsmtp1.Send(idmessage1);