function sendMail(STRhost:string;INTport:integer;STRuserName:string;STRpassword:string;STRfromEmail:string;STRReEmail:string;STRsubject:string;STRfname:string):integer;stdcall;
var
IdMessage1: TIdMessage;
IdSASLLogin1: TIdSASLLogin;
IdSMTP1: TIdSMTP;
LHlogin: TIdUserPassProvider;
begin
result:=0;
idMessage1:=TIdMessage.Create();
IdSASLLogin1:=TIdSASLLogin.Create();
IdSMTP1:=TIdSMTP.Create();
LHlogin:=TIdUserPassProvider.Create();
with idMessage1 do
begin
ContentType:='text/html';
Body.LoadFromFile(STRfname);
From.Address:=STRfromEMail;
Recipients.EMailAddresses:=STRReEmail;
IDMessage1.Subject:=STRsubject;
end;
with IDSMTP1 do
begin
Host:=STRHost;
port:=INTport;
username:=STRusername;
password:=STRpassword;
LHlogin.Username:=STRuserName;
LHlogin.Password:=STRpassWord;
IDSMTP1.AuthType:=atSASL;
IDSMTP1.SASLMechanisms.Add.SASL:=IdSASLLogin1;
IdSASLLogin1.UserPassProvider:=LHlogin;
try
idsmtp1.Connect;
idsmtp1.Authenticate;
idsmtp1.Send(idMessage1);
idsmtp1.Disconnect;
result:=1;
finally
end;
end;
idMessage1.Free;
IdSASLLogin1.Free;
IdSMTP1.Free;
LHlogin.Free;
end;