procedure TYourClass.Send
begin
SMTP := TIdSMTP.Create(
nil);
try
SMTP.IOHandler := CreateSSLHandler(
SMTP);
// siehe unten
SMTP.UseTLS := utUseImplicitTLS;
SMTP.Host := FConfig.SMTPHost;
SMTP.Port := FConfig.SMTPPort;
SMTP.Username := FConfig.SMTPUsername;
SMTP.Password := FConfig.SMTPPassword;
SMTP.Connect;
//...
end
function TYourClass.CreateSSLHandler(Owner: TComponent): TIdSSLIOHandlerSocketOpenSSL;
begin
Result := TIdSSLIOHandlerSocketOpenSSL.Create(Owner);
Result.OnVerifyPeer := SSLVerifyPeerEventHandler;
Result.SSLOptions.Method := sslvSSLv3;
Result.SSLOptions.VerifyMode := [sslvrfClientOnce];
end;
function TYourClass.SSLVerifyPeerEventHandler(Certificate: TIdX509; AOk: Boolean; ADepth,
AError: Integer): Boolean;
begin
Result := AOK
or
// Selbsterstellte Zertifikate akzeptieren
(AError = X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
end;