139
try
ServerAddress := Trim(Q.FieldByName ('Email_Адрес_сервера').Value);
Login := Trim(Q.FieldByName ('Email').Value);
Password := Q.FieldByName ('Email_Пароль').Value;
ServerPort := Q.FieldByName ('Email_Порт').AsInteger;
Email := Trim(Email);
if (Email = '') then
raise Exception.Create('Email получателя не задан');
if (ServerPort <= 0) then
raise Exception.Create('Порт почтового сервера не задан. См.
"Параметры"');
if (ServerAddress = '') then
raise Exception.Create('Адрес почтового сервера не задан. См.
"Параметры"');
if (Login = '') then
raise Exception.Create('Адрес электронной почты не задан. См.
"Параметры"');
if (Password = '') then
raise Exception.Create('Пароль для электронной почты не задан. См.
"Параметры"');
IdSMTP := TIdSMTP.Create(nil);
try
IdSMTP.Disconnect;
IdSMTP.Port := ServerPort;
IdSMTP.Host := ServerAddress;
IdSMTP.AuthType := satDefault;
IdSMTP.Username := Login;
IdSMTP.Password := Password;
IdSMTP.ConnectTimeout := 1000;
IdSMTP.Connect;