Skip to content

Commit

Permalink
Adjusted new messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dliocode committed May 6, 2021
1 parent 47c09aa commit e046c13
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/SendEmail.pas
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ constructor TSendEmail.Create;
OnWork := Work;
OnWorkEnd := WorkEnd;
ManagedIOHandler := True;
PipeLine := False;
end;

with FIdSSLOpenSSL do
Expand Down Expand Up @@ -570,7 +571,7 @@ function TSendEmail.Connect: TSendEmail;
except
on E: Exception do
begin
Log(E.Message, True);
Log('Except: ' + E.Message, True);
Log('Email not connected!');
raise;
end;
Expand Down Expand Up @@ -598,9 +599,10 @@ function TSendEmail.Send(const ADisconnectAfterSending: Boolean = True): TSendEm
except
on E: Exception do
begin
Log(E.Message, True);
Log('Except: ' + E.Message, True);

if E.Message.ToUpper.Contains('CLOSING CONNECTION') or
if
E.Message.ToUpper.Contains('CLOSING CONNECTION') or
E.Message.ToUpper.Contains('TOO MANY MESSAGES')
then
begin
Expand All @@ -621,6 +623,22 @@ function TSendEmail.Send(const ADisconnectAfterSending: Boolean = True): TSendEm
if E.Message.ToUpper.Contains('NOT CONNECTED') then
raise Exception.Create('Not connected to internet!');

if
E.Message.ToUpper.Contains('NO SUCH USER HERE') or
E.Message.ToUpper.Contains('USER UNKNOWN') or
E.Message.ToUpper.Contains('MAILBOX UNAVAILABLE')
then
raise Exception.Create('The recipient''s mailbox does not exist in the destination domain. It was probably typed incorrectly!');

if
E.Message.ToUpper.Contains('MAILBOX IS FULL') or
E.Message.ToUpper.Contains('MAIL QUOTA EXCEEDED') or
E.Message.ToUpper.Contains('MAILBOX FULL') or
E.Message.ToUpper.Contains('DISK QUOTA EXCEEDED') or
E.Message.ToUpper.Contains('USER IS OVER THE QUOTA')
then
raise Exception.Create('It means that the recipient''s inbox is full and cannot receive any more messages!');

raise Exception.Create(E.Message);
end;
end;
Expand Down Expand Up @@ -672,7 +690,7 @@ function TSendEmail.Disconnect: TSendEmail;
FIdSMTP.Disconnect(False);
Log('Disconnected');
except
Log('Disconnected with error');
Log('Except: Disconnected with error');
end;

if FSSL or FTLS then
Expand Down Expand Up @@ -796,4 +814,4 @@ finalization

FreeAndNil(TSendEmail.RW);

end.
end.

0 comments on commit e046c13

Please sign in to comment.