@@ -34,7 +34,6 @@ TSendEmail = class
34
34
class var RW: TMultiReadExclusiveWriteSynchronizer;
35
35
class var FInstance: TSendEmail;
36
36
37
- function IsConnected : Boolean;
38
37
procedure Reconnect (AResend: Boolean = False);
39
38
40
39
procedure LogSMTPStatus (ASender: TObject; const AStatus: TIdStatus; const AStatusText: string);
@@ -68,6 +67,7 @@ TSendEmail = class
68
67
function Send (const ADisconnectAfterSending: Boolean = True): TSendEmail;
69
68
function SendAsync (const ACallBack: TProc<Boolean, string> = nil ; const ADisconnectAfterSending: Boolean = True): TSendEmail;
70
69
function Disconnect : TSendEmail;
70
+ function IsConnected : Boolean;
71
71
72
72
function OnLog (const AExecute: TProc<string>; const ALogMode: TLogMode = lmComponent): TSendEmail;
73
73
function OnWorkBegin (const AExecute: TProc<Int64>): TSendEmail;
@@ -701,6 +701,28 @@ function TSendEmail.Disconnect: TSendEmail;
701
701
end ;
702
702
end ;
703
703
704
+ function TSendEmail.IsConnected : Boolean;
705
+ begin
706
+ Result := False;
707
+
708
+ try
709
+ Result := FIdSMTP.Connected;
710
+ except
711
+ on E: Exception do
712
+ begin
713
+ if E.Message.ToUpper.Contains(' CLOSING CONNECTION' ) or
714
+ E.Message.ToUpper.Contains(' SSL3_GET_RECORD' )
715
+ then
716
+ try
717
+ Reconnect(False);
718
+ Result := True;
719
+ except
720
+ Exit;
721
+ end ;
722
+ end ;
723
+ end ;
724
+ end ;
725
+
704
726
function TSendEmail.OnLog (const AExecute: TProc<string>; const ALogMode: TLogMode = lmComponent): TSendEmail;
705
727
begin
706
728
Result := Self;
@@ -727,28 +749,6 @@ function TSendEmail.OnWorkEnd(const AExecute: TProc): TSendEmail;
727
749
FWorkEnd := AExecute;
728
750
end ;
729
751
730
- function TSendEmail.IsConnected : Boolean;
731
- begin
732
- Result := False;
733
-
734
- try
735
- Result := FIdSMTP.Connected;
736
- except
737
- on E: Exception do
738
- begin
739
- if E.Message.ToUpper.Contains(' CLOSING CONNECTION' ) or
740
- E.Message.ToUpper.Contains(' SSL3_GET_RECORD' )
741
- then
742
- try
743
- Reconnect(False);
744
- Result := True;
745
- except
746
- Exit;
747
- end ;
748
- end ;
749
- end ;
750
- end ;
751
-
752
752
procedure TSendEmail.Reconnect (AResend: Boolean = False);
753
753
begin
754
754
if AResend then
0 commit comments