我最近使用Delphi 5和Indy 10从fulgan下载。 当提供的凭据不正确时,会发生访问冲突错误。验证函数似乎产生错误。 也无法通过访问冲突错误,导致程序在没有任何警告的情况下关闭。 这是一个示例代码:
procedure TForm1.Button2Click(Sender: TObject);
var IDSMTP1: TIdSMTP;
Idmessage1: TIDMessage;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
begin
IDSMTP1 := TIdSMTP.Create;
IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create;
try
with IDSMTP1 do begin
Host := 'smtp.gmail.com';
Port := 465;
Username := 'email@gmail.com';
Password := 'password';
AuthType := satDefault;
IdSSLIOHandlerSocketOpenSSL1.SSLOptions.SSLVersions := [sslvTLSv1];
IOHandler := IdSSLIOHandlerSocketOpenSSL1;
UseTLS := utUseRequireTLS;
end;
Idmessage1 := TIDMessage.Create;
try
with Idmessage1 do begin
Subject := 'test';
From.Address := 'email@gmail.com';
From.Name := 'testname';
Recipients.EMailAddresses := 'email@gmail.com';
end;
with IDSMTP1 do begin
if not Connected then
Connect;
try
Authenticate;
Send(IdMessage1);
except
end;
Disconnect;
end;
finally
Idmessage1.Free;
end;
finally
IDSMTP1.Free;
IdSSLIOHandlerSocketOpenSSL1.Free;
end;
end;
提前谢谢。