Evo Indy primer (ne testirano), ne zaboravi da moraš imati openSSL dllove (libeay32.dll, ssleay32.dll, zlib1.dll).
Code:
uses
IdSmtp, IdMessage, IdPop3, IdAttachmentFile, IdSSLOpenSSL, IdExplicitTLSClientServerBase;
var
Smtp: TIdSmtp;
Msg: TIdMessage;
begin
Smtp := TIdSMTP.Create(nil);
try
Msg := TIdMessage.Create(Smtp);
with Msg do
begin
Subject := 'Proba';
From.Text := '
[email protected]';
Recipients.EMailAddresses := ''
[email protected]';
Date := Now;
end;
with Smtp do
begin
try
MailAgent := 'Test prg';
Host := 'smtp.gmail.com';
Smtp.Port := 465;
Smtp.Username := 'UserName';
Smtp.Password := 'Pass';
Smtp.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(SMTP);
Smtp.UseTLS := utUseExplicitTLS;
Smtp.Connect;
Send(Msg);
Disconnect;
except
on E: Exception do
begin
raise;
end;
end;
end;
finally
Smtp.Free;
end;