-
Notifications
You must be signed in to change notification settings - Fork 6
/
uSMTPClient.pas
990 lines (957 loc) · 40.4 KB
/
uSMTPClient.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
unit uSMTPClient;
{******************************************************************************}
{* Package SMTP Client Unit *}
{* Revolutionary Confederation of Anarcho Syndicalists *}
{* Written by: black.rabbit 2012 *}
{******************************************************************************}
interface
{$I 'std.inc'}
uses
Windows, SysUtils, Variants, Classes,
Controls, ComCtrls, Gauges,
sListView,
{ utils }
DateUtils, Utils, Strings, VarRecs, Versions, EClasses,
DllThreads,
{ synapse }
WinSock, BlckSock, SynaUtil, SMTPSend,
PingSend,
{ smtp }
SMTPClient,
{ kernel }
Kernel, ProtoClasses, CryptoClasses, MetaClasses, ParaClasses,
HypoClasses, HyperClasses,
{ engine }
Engine,
{ SQLite }
SQLite3, SQLite3DLL, SQLiteTable3;
{ èêîíêè }
const
pckDefault = 0;
pckEmpty = 1;
pckFull = 2;
pckTest = 3;
pckError = 4;
pckSend = 5;
pckReceive = 6;
type
PLogRecord = ^TLogRecord;
TLogRecord = packed record
Caption : ShortString;
ImageIndex : Integer;
Sender : ShortString;
Receiver : ShortString;
Message : ShortString;
end;
type
{ îøèáêà smtp-êëèåíòà }
{$M+}
ESMTPClientError = class (EThreadError) end;
{$M-}
{ ïîòîê ïàêåòíîãî êëèåíòà }
{$M+}
CSMTPPackageClient = class of TSMTPPackageClient;
PSMTPPackageClient = ^TSMTPPackageClient;
TSMTPPackageClient = class (TDllThread)
public
class procedure _raise (anArgs: array of const;
const anEGUID: String = ''); override;
class procedure _raise (anArgs: array of const;
anEGUID: array of const); override;
private
f_Threads: TDllThreads; { äî÷åðíèå ïîòîêè }
f_Host: String; { smtp-õîñò }
f_Port: WORD; { smtp-ïîðò }
f_Login: String; { ëîãèí ïî÷òû }
f_Password: String; { ïàðîëü ïî÷òû }
f_AutoTLS: Boolean; { auto tls }
f_FullSSL: Boolean; { full ssl }
f_ProxyHost: String; { õîñò proxy-ñåðâåðà }
f_ProxyPort: WORD; { ïîðò proxy-ñåðâåðà }
f_ProxyLogin: String; { ëîãèí íà proxy-ñåðâåð }
f_ProxyPassword: String; { ïàðîëü íà proxy-ñåðâåð }
f_ProxyProtocol: String; { ïðîòîêîë proxy-ñåðâåðà }
f_TimeOut: LongWord; { âðåìÿ îæèäàíèÿ ms }
f_DBFileName: String; { ôàéë áàçû äàííûõ }
f_DB: TSQLiteDatabase; { îáúåêò áàçû äàííûõ }
f_ListView: TsListView; { ëîã }
f_Gauge: TGauge; { ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_StatusPanel: TStatusPanel; { ñòðîêà ñîñòîÿíèÿ çàãðóçêè }
f_Users: TUsers; { ñïèñîê êîíòàêòîâ â ðàññûëêå }
f_UserIndex: LongInt; { ïîçèöèÿ â îáõîäå ñïèñêà }
public
// DBFileName, Host, Port, Login, Password, AutoTLS, FullSSL,
// ListView, Gauge, StatusPanel, TimeOut,
// ProxyHost, ProxyPort, ProxyLogin, ProxyPassword, ProxyProtocol
constructor Create (anArgs: array of const); override;
destructor Destroy; override;
public
procedure Main; override;
procedure Return; override;
protected
procedure WriteStatus (const aMessage: String); overload;
procedure WriteStatus (const aMessage: String;
aParams: array of const); overload;
public
property Threads: TDllThreads read f_Threads write f_Threads;
property Host: String read f_Host write f_Host;
property Port: WORD read f_Port write f_Port;
property Login: String read f_Login write f_Login;
property Password: String read f_Password write f_Password;
property AutoTLS: Boolean read f_AutoTLS write f_AutoTLS;
property FullSSL: Boolean read f_FullSSL write f_FullSSL;
property ProxyHost: String read f_ProxyHost write f_ProxyHost;
property ProxyPort: WORD read f_ProxyPort write f_ProxyPort;
property ProxyLogin: String read f_ProxyLogin write f_ProxyLogin;
property ProxyPassword: String read f_ProxyPassword write f_ProxyPassword;
property ProxyProtocol: String read f_ProxyProtocol write f_ProxyProtocol;
property TimeOut: LongWord read f_TimeOut write f_TimeOut;
property DBFileName: String read f_DBFileName;
property DB: TSQLiteDatabase read f_DB write f_DB;
property ListView: TsListView read f_ListView write f_ListView;
property Gauge: TGauge read f_Gauge write f_Gauge;
property StatusPanel: TStatusPanel read f_StatusPanel write f_StatusPanel;
property Users: TUsers read f_Users write f_Users;
property UserIndex: LongInt read f_UserIndex write f_UserIndex;
end;
{$M-}
{ äî÷åðíèé ïîòîê ïàêåòíîãî êëèåíòà }
{$M+}
CSMTPPackageClientThread = class of TSMTPPackageClientThread;
PSMTPPackageClientThread = ^TSMTPPackageClientThread;
TSMTPPackageClientThread = class (TDllThread)
public
class procedure _raise (anArgs: array of const;
const anEGUID: String = ''); override;
class procedure _raise (anArgs: array of const;
anEGUID: array of const); override;
private
f_SMTP: TSMTPClient; { êëèåíò }
f_Host: String; { smtp-õîñò }
f_Port: WORD; { smtp-ïîðò }
f_Login: String; { ëîãèí ïî÷òû }
f_Password: String; { ïàðîëü ïî÷òû }
f_AutoTLS: Boolean; { auto tls }
f_FullSSL: Boolean; { full ssl }
f_ProxyHost: String; { õîñò proxy-ñåðâåðà }
f_ProxyPort: WORD; { ïîðò proxy-ñåðâåðà }
f_ProxyLogin: String; { ëîãèí íà proxy-ñåðâåð }
f_ProxyPassword: String; { ïàðîëü íà proxy-ñåðâåð }
f_ProxyProtocol: String; { ïðîòîêîë proxy-ñåðâåðà }
f_TimeOut: LongWord; { âðåìÿ îæèäàíèÿ ms }
f_DBFileName: String; { ôàéë áàçû äàííûõ }
f_DB: TSQLiteDatabase; { îáúåêò áàçû äàííûõ }
f_ReceiverID: TID; { èäåíòèôèêàòîð ïîëó÷àòåëÿ }
f_Receiver: TUser; { ïîëó÷àòåëü }
f_ListView: TsListView; { ëîã }
f_Gauge: TGauge; { ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_StatusPanel: TStatusPanel; { ñòðîêà ñîñòîÿíèÿ çàãðóçêè }
f_Packages: TPackages; { ñïèñîê ïàêåòîâ äëÿ ðàññûëêè }
f_PackageIndex: LongInt; { ïîçèöèÿ â îáõîäå ñïèñêà }
f_IdleTime: LongInt; { âðåìÿ îæèäàíèÿ ìåæäó çàïðîñàìè }
private
f_Log: TItems;
f_Status: String;
f_MaxProgress: WORD;
f_Progress: WORD;
public
// DBFileName, ReceiverID, Host, Port, Login, Password, AutoTLS, FullSSL,
// ListView, Gauge, StatusPanel, TimeOut,
// ProxyHost, ProxyPort, ProxyLogin, ProxyPassword, ProxyProtocol
constructor Create (anArgs: array of const); override;
destructor Destroy; override;
public
procedure Main; override;
procedure Return; override;
protected
procedure WriteStatus (const aMessage: String); overload;
procedure WriteStatus (const aMessage: String;
aParams: array of const); overload;
procedure WriteLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
const anImageIndex: Integer = pckDefault;
const aPackageType: String = '';
const aMetaClassID: String = ''); overload;
procedure WriteLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
aParams: array of const;
const anImageIndex: Integer = pckDefault;
const aPackageType: String = '';
const aMetaClassID: String = ''); overload;
public
property SMTP: TSMTPClient read f_SMTP;
property Host: String read f_Host write f_Host;
property Port: WORD read f_Port write f_Port;
property Login: String read f_Login write f_Login;
property Password: String read f_Password write f_Password;
property AutoTLS: Boolean read f_AutoTLS write f_AutoTLS;
property FullSSL: Boolean read f_FullSSL write f_FullSSL;
property ProxyHost: String read f_ProxyHost write f_ProxyHost;
property ProxyPort: WORD read f_ProxyPort write f_ProxyPort;
property ProxyLogin: String read f_ProxyLogin write f_ProxyLogin;
property ProxyPassword: String read f_ProxyPassword write f_ProxyPassword;
property ProxyProtocol: String read f_ProxyProtocol write f_ProxyProtocol;
property TimeOut: LongWord read f_TimeOut write f_TimeOut;
property DBFileName: String read f_DBFileName;
property DB: TSQLiteDatabase read f_DB write f_DB;
property ReceiverID: TID read f_ReceiverID write f_ReceiverID;
property Receiver: TUser read f_Receiver;
property ListView: TsListView read f_ListView write f_ListView;
property Gauge: TGauge read f_Gauge write f_Gauge;
property StatusPanel: TStatusPanel read f_StatusPanel write f_StatusPanel;
property Packages: TPackages read f_Packages write f_Packages;
property PackageIndex: LongInt read f_PackageIndex write f_PackageIndex;
property IdleTime: LongInt read f_IdleTime write f_IdleTime;
property Log: TItems read f_Log write f_Log;
property Status: String read f_Status write f_Status;
property MaxProgress: WORD read f_MaxProgress write f_MaxProgress;
property Progress: WORD read f_Progress write f_Progress;
end;
{$M-}
{ TSMTPPackageClient Errors }
resourcestring
ERR_TSMTPPACKAGECLIENT_INCORRECT_DATABASE = 'Íå èíèöèàëèçèðîâàí îáúåêò ÁÄ!';
ERR_TSMTPPACKAGECLIENT_INVALID_HOST = 'Íåêîððåêòíûé smtp-õîñò!';
ERR_TSMTPPACKAGECLIENT_INVALID_PORT = 'Íåêîððåêòíûé smtp-ïîðò!';
ERR_TSMTPPACKAGECLIENT_INVALID_LOGIN = 'Íåêîððåêòíûé ëîãèí ê smtp-ñåðâåðó!';
ERR_TSMTPPACKAGECLIENT_INVALID_PROXY_HOST = 'Íåêîððåêòíûé proxy-õîñò!';
ERR_TSMTPPACKAGECLIENT_INVALID_PROXY_PORT = 'Íåêîððåêòíûé proxy-ïîðò!';
ERR_TSMTPPACKAGECLIENT_INVALID_PROXY_PROTOCOL = 'Íåêîððåêòíûé proxy-ïðîòîêîë!';
ERR_TSMTPPACKAGECLIENT_INVALID_TIMEOUT = 'Íåêîððåêòíûé òàéìàóò äëÿ ñîåäèíåíèé!';
ERR_TSMTPPACKAGECLIENT_CREATE = 'Îøèáêà ñîçäàíèÿ ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENT_DESTROY = 'Îøèáêà óíè÷òîæåíèÿ ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENT_MAIN = 'Îøèáêà âûïîëíåíèÿ ãëàâíîé ôóíêöèè ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENT_RETURN = 'Îøèáêà ôóíêöèè âîçâðàòà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENT_WRITE_STATUS = 'Îøèáêà îòîáðàæåíèÿ ñòàòóñà!';
{ TSMTPPackageClientThread Errors }
resourcestring
ERR_TSMTPPACKAGECLIENTTHREAD_INCORRECT_DATABASE = 'Íå èíèöèàëèçèðîâàí îáúåêò ÁÄ!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_RECEIVER_ID = 'Íåêîððåêòíûé èäåíòèôèêàòîð ïîëó÷àòåëÿ!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_RECEIVER = 'Íåêîððåêòíûé ïîëó÷àòåëü!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_HOST = 'Íåêîððåêòíûé smtp-õîñò!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PORT = 'Íåêîððåêòíûé smtp-ïîðò!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_LOGIN = 'Íåêîððåêòíûé ëîãèí ê smtp-ñåðâåðó!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PROXY_HOST = 'Íåêîððåêòíûé proxy-õîñò!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PROXY_PORT = 'Íåêîððåêòíûé proxy-ïîðò!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PROXY_PROTOCOL = 'Íåêîððåêòíûé proxy-ïðîòîêîë!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_TIMEOUT = 'Íåêîððåêòíûé òàéìàóò äëÿ ñîåäèíåíèé!';
ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_DATA = 'Íåêîððåêòíûå äàííûå!';
ERR_TSMTPPACKAGECLIENTTHREAD_CREATE = 'Îøèáêà ñîçäàíèÿ äî÷åðíåãî ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENTTHREAD_DESTROY = 'Îøèáêà óíè÷òîæåíèÿ äî÷åðíåãî ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENTTHREAD_MAIN = 'Îøèáêà âûïîëíåíèÿ ãëàâíîé ôóíêöèè äî÷åðíåãî ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENTTHREAD_RETURN = 'Îøèáêà âûïîëíåíèÿ ôóíêöèè âîçâðàòà äî÷åðíåãî ïîòîêà ïàêåòíîãî êëèåíòà!';
ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_STATUS = 'Îøèáêà îòîáðàæåíèÿ ñòàòóñà!';
ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_LOG = 'Îøèáêà çàïèñè â ëîã!';
{ TSMTPPackage Hints }
resourcestring
MSG_TSMTPPACKAGE_SEND_TO = 'Îòïðàâêà ïàêåòîâ äëÿ ''%s''...';
MSG_TSMTPPACKAGE_SEND_ERROR = 'Îøèáêà îòïðàâêè ïàêåòà. SMTP Error: %d';
MSG_TSMTPPACKAGE_SENDED_PACKAGE = 'Ïàêåò ''%s'' îòïðàâëåí ïîëó÷àòåëþ.';
MSG_TSMTPPACKAGE_RECEIVED_PACKAGE = 'Ïàêåò ''%s'' äîñòàâëåí ïîëó÷àòåëþ.';
MSG_TSMTPPACKAGE_EXECUTED_PACKAGE = 'Ïàêåò ''%s'' îáðàáîòàí ïîëó÷àòåëåì.';
MSG_TSMTPPACKAGE_REJECTED_PACKAGE = 'Ïàêåò ''%s'' îòâåðãíóò ïîëó÷àòåëåì.';
implementation
{ TSMTPPackageClient }
class procedure TSMTPPackageClient._raise (anArgs: array of const;
const anEGUID: String = '');
begin
raise ESMTPClientError.Create ( _([self],anArgs), anEGUID );
end;
class procedure TSMTPPackageClient._raise (anArgs: array of const;
anEGUID: array of const);
begin
raise ESMTPClientError.Create ( _([self],anArgs), anEGUID );
end;
constructor TSMTPPackageClient.Create (anArgs: array of const);
var
I : Integer;
args : array_of_const;
OBJ : TObject;
begin
try
{ ïåðåäàåì ïàðàìåòðû ñîçäàíèÿ áàçîâîãî ïîòîêà,
íà÷èíàÿ ñ ñåìíàäöàòîãî àðãóìåíòà }
if ( High (anArgs) >= 16 ) then
begin
SetLength ( Args, High (anArgs)-16 +1 );
for I := 16 to High (anArgs) do
args [I-16] := anArgs [I];
end
else
args := _array_of_const ([]);
inherited Create (args);
{ ÿâíî óêàçûâàåì íà íåîáõîäèìîñòü óíè÷òîæåíèÿ ïîòîêà ïî îêîí÷àíèþ ðàáîòû }
FreeOnTerminate := TRUE;
{ èìÿ ïîòîêà }
Name := ClassName;
{ ïðèîðèòåò }
Priority := tpIdle;
{ ïåðâûé ïàðàìåòð - ôàéë ÁÄ }
f_DBFileName := '';
f_DB := NIL;
if notEmpty (0,anArgs) then
begin
f_DBFileName := toString (anArgs [0]);
f_DB := TSQLiteDatabase.Create (f_DBFileName);
end;
if ( not Assigned (f_DB) ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INCORRECT_DATABASE);
{ âòîðîé ïàðàìåòð - õîñò smtp-ñåðâåðà }
f_Host := '';
if notEmpty (1,anArgs) then
begin
f_Host := toString (anArgs [1]);
end;
if isEmpty (Host) {or not isIPAddress (Host)} then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_HOST);
{ òðåòèé ïàðàìåòð - ïîðò smtp-ñåðâåðà }
f_Port := 0;
if notEmpty (2,anArgs) then
begin
f_Port := toInteger (anArgs [2]);
end;
if ( Port <= 0 ) and ( Host <> '' ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_PORT);
{ ÷åòâåðòûé ïàðàìåòð - ëîãèí ê smtp-ñåðâåðó }
f_Login := '';
if notEmpty (3,anArgs) then
begin
f_Login := toString (anArgs [3]);
end;
if isEmpty (Login) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_LOGIN);
{ ïÿòûé ïàðàìåòð - ïàðîëü ê smtp-ñåðâåðó }
f_Password := '';
if notEmpty (4,anArgs) then
begin
f_Password := toString (anArgs [4]);
end;
{ øåñòîé ïàðàìåòð - AutoTLS }
f_AutoTLS := FALSE;
if notEmpty (5,anArgs) then
begin
f_AutoTLS := toBoolean (anArgs [5]);
end;
{ ñåäüìîé ïàðàìåòð - FullSSL }
f_FullSSL := FALSE;
if notEmpty (6,anArgs) then
begin
f_FullSSL := toBoolean (anArgs [6]);
end;
{ âîñüìîé ïàðàìåòð - ListView
ëîã ïî÷òû }
f_ListView := NIL;
if notEmpty (7,anArgs) then
begin
OBJ := toObject (anArgs [7]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TsListView) ) then
f_ListView := TsListView (OBJ);
end;
{ äåâÿòûé ïàðàìåòð - Gauge
ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_Gauge := NIL;
if notEmpty (8,anArgs) then
begin
OBJ := toObject (anArgs [8]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TControl) ) then
f_Gauge := TGauge (OBJ);
end;
{ äåñÿòûé ïàðàìåòð - StatusPanel
ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_StatusPanel := NIL;
if notEmpty (9,anArgs) then
begin
OBJ := toObject (anArgs [9]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TStatusPanel) ) then
f_StatusPanel := TStatusPanel (OBJ);
end;
{ îäèííàäöàòûé ïàðàìåòð - âðåìÿ îæèäàíèÿ ms }
f_TimeOut := 120000;
if notEmpty (10,anArgs) then
begin
f_TimeOut := toInteger (anArgs [10]);
end;
if ( TimeOut = 0 ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_TIMEOUT);
{ äâåíàäöàòûé ïàðàìåòð - õîñò proxy-ñåðâåðà }
f_ProxyHost := '';
if notEmpty (11,anArgs) then
begin
f_ProxyHost := toString (anArgs [11]);
end;
if ( ProxyHost <> '' ) and not isIPAddress (ProxyHost) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_PROXY_HOST);
{ òðèíàäöàòûé ïàðàìåòð - ïîðò proxy-ñåðâåðà }
f_ProxyPort := 0;
if notEmpty (12,anArgs) then
begin
f_ProxyPort := toInteger (anArgs [12]);
end;
if ( ProxyPort <= 0 ) and ( ProxyHost <> '' ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENT_INVALID_PROXY_PORT);
{ ÷åòûðíàäöàòûé ïàðàìåòð - ëîãèí proxy-ñåðâåðà }
f_ProxyLogin := '';
if notEmpty (13,anArgs) then
begin
f_ProxyLogin := toString (anArgs [13]);
end;
{ ïÿòíàäöàòûé ïàðàìåòð - ïàðîëü proxy-ñåðâåðà }
f_ProxyPassword := '';
if notEmpty (14,anArgs) then
begin
f_ProxyPassword := toString (anArgs [14]);
end;
{ øåñòíàäöàòûé ïàðàìåòð - ïðîòîêîë proxy-ñåðâåðà }
f_ProxyProtocol := '';
if notEmpty (15,anArgs) then
begin
f_ProxyProtocol := toString (anArgs [15]);
end;
{ ñîçäàåì êîíòåéíåð äî÷åðíèõ ïîòîêîâ }
f_Threads := TDllThreads.Create ([]);
{ ñïèñîê ïîëüçîâàòåëåé }
f_Users := NIL;
f_UserIndex := -1;
except on E: Exception do
_raise ([ 'Create', ERR_TSMTPPACKAGECLIENT_CREATE, E, Exception (FatalException) ],
['{4EB8AAA0-18F0-4A07-B8AD-3436B8B84C13}']);
end;
end;
destructor TSMTPPackageClient.Destroy;
begin
try
try
_FillChar ( f_Host, Length (f_Host), $00 );
f_Port := 0;
_FillChar ( f_Login, Length (f_Login), $00 );
_FillChar ( f_Password, Length (f_Password), $00 );
_FillChar ( f_ProxyHost, Length (f_ProxyHost), $00 );
f_ProxyPort := 0;
_FillChar ( f_ProxyLogin, Length (f_ProxyLogin), $00 );
_FillChar ( f_ProxyPassword, Length (f_ProxyPassword), $00 );
if Assigned (Threads) then
Threads.Terminate;
FreeAndNil (f_Threads);
FreeAndNil (f_Users);
FreeAndNil (f_DB);
finally
inherited Destroy;
end;
except on E: Exception do
_raise ([ 'Destroy', ERR_TSMTPPACKAGECLIENT_DESTROY, E, Exception (FatalException) ],
['{7FDDAECC-A00B-40A6-9111-B18CC27FF929}']);
end;
end;
procedure TSMTPPackageClient.Main;
begin
try
if Terminated then Exit;
inherited Main;
if not Assigned (Users) then
try
f_Users := TUsers.Load (DB,[ _([]),
_([]),
_([USER_ID]) ],
[],
[],
[objSimple]) as TUsers;
except
FreeAndNil (f_Users);
end;
Sleep (TimeOut*10);
except on E: Exception do
_raise ([ 'Main', ERR_TSMTPPACKAGECLIENT_MAIN, E, Exception (FatalException) ],
['{B32D182D-D54F-49D7-BF26-3F73FD05F2CC}']);
end;
end;
procedure TSMTPPackageClient.Return;
var
Thr : TSMTPPackageClientThread;
begin
try
if Terminated then Exit;
if ( not Assigned (Users) or (Users.Count <= 0) ) then
Terminate
else if ( UserIndex >= Users.Count - 1 ) then
begin
UserIndex := -1;
end
{ åñëè îäèí èç äî÷åðíèõ ïîòîêîâ çàâåðøèëñÿ - çàïóñêàåì åãî ñíîâà }
else if ( UserIndex <= Users.Count - 1 ) and
not Assigned ( Threads.ItemOf [ Users.ItemAt [UserIndex+1].KeyHash ] ) then
try
inherited Return;
UserIndex := UserIndex + 1;
if notEmpty ( Users.ItemAt [UserIndex].EMail ) then
try
Thr := TSMTPPackageClientThread.Create ([ DBFileName,
Users.ItemAt [UserIndex].ID,
Host, Port,
Login, Password,
AutoTLS, FullSSL,
ListView,
Gauge,
StatusPanel,
TimeOut,
ProxyHost, ProxyPort,
ProxyLogin, ProxyPassword,
ProxyProtocol,
FALSE, TRUE,
TP_IDLE,
NIL, NIL,
Users.ItemAt [UserIndex].KeyHash ]);
if ( Threads.Add (Thr) < 0 ) then
FreeAndNil (Thr);
except
FreeAndNil (Thr);
end;
except on E: Exception do
WriteStatus (E.Message);
end;
except on E: Exception do
_raise ([ 'Return', ERR_TSMTPPACKAGECLIENT_RETURN, E, Exception (FatalException) ],
['{2F0B941D-0C1F-406F-9678-4E3709369E9E}']);
end;
end;
procedure TSMTPPackageClient.WriteStatus (const aMessage: String);
begin
try
if Assigned (StatusPanel) then
begin
StatusPanel.Text := aMessage;
ProcessMessages;
end;
except on E: Exception do
_raise (['WriteStatus',ERR_TSMTPPACKAGECLIENT_WRITE_STATUS,E],
['{1965E534-BC3E-4035-98F7-BB018B88422E}']);
end;
end;
procedure TSMTPPackageClient.WriteStatus (const aMessage: String;
aParams: array of const);
begin
try
WriteStatus ( Format (aMessage,aParams) );
except on E: Exception do
_raise (['WriteStatus',ERR_TSMTPPACKAGECLIENT_WRITE_STATUS,E],
['{9A423386-583B-4521-8A0C-6365B188B92E}']);
end;
end;
{ TSMTPPackageClientThread }
class procedure TSMTPPackageClientThread._raise (anArgs: array of const;
const anEGUID: String = '');
begin
raise ESMTPClientError.Create ( _([self],anArgs), anEGUID );
end;
class procedure TSMTPPackageClientThread._raise (anArgs: array of const;
anEGUID: array of const);
begin
raise ESMTPClientError.Create ( _([self],anArgs), anEGUID );
end;
constructor TSMTPPackageClientThread.Create (anArgs: array of const);
var
I : Integer;
args : array_of_const;
OBJ : TObject;
begin
try
{ ïåðåäàåì ïàðàìåòðû ñîçäàíèÿ áàçîâîãî ïîòîêà,
íà÷èíàÿ ñ âîñåìíàäöàòîãî àðãóìåíòà }
if ( High (anArgs) >= 17 ) then
begin
SetLength ( Args, High (anArgs)-17 +1 );
for I := 17 to High (anArgs) do
args [I-17] := anArgs [I];
end
else
args := _array_of_const ([]);
inherited Create (args);
{ ÿâíî óêàçûâàåì íà íåîáõîäèìîñòü óíè÷òîæåíèÿ ïîòîêà ïî îêîí÷àíèþ ðàáîòû }
FreeOnTerminate := TRUE;
{ ïåðâûé ïàðàìåòð - ôàéë ÁÄ }
f_DBFileName := '';
f_DB := NIL;
if notEmpty (0,anArgs) then
begin
f_DBFileName := toString (anArgs [0]);
f_DB := TSQLiteDatabase.Create (f_DBFileName);
end;
if ( not Assigned (f_DB) ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INCORRECT_DATABASE);
{ âòîðîé ïàðàìåòð - ReceiverID
èäåíòèôèêàòîð ïîëó÷àòåëÿ }
f_ReceiverID := 0;
if notEmpty (1,anArgs) then
begin
f_ReceiverID := toInt64 (anArgs [1]);
end;
if not ( ReceiverID > 0 ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_RECEIVER_ID);
f_Receiver := TUser.Load (DB,ReceiverID,[objSimple]) as TUser;
if not Assigned (Receiver) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_RECEIVER);
{ òðåòèé ïàðàìåòð - õîñò smtp-ñåðâåðà }
f_Host := '';
if notEmpty (2,anArgs) then
begin
f_Host := toString (anArgs [2]);
end;
if isEmpty (Host) {or not isIPAddress (Host)} then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_HOST);
{ ÷åòâåðòûé ïàðàìåòð - ïîðò smtp-ñåðâåðà }
f_Port := 0;
if notEmpty (3,anArgs) then
begin
f_Port := toInteger (anArgs [3]);
end;
if ( Port <= 0 ) and ( Host <> '' ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PORT);
{ ïÿòûé ïàðàìåòð - ëîãèí ê smtp-ñåðâåðó }
f_Login := '';
if notEmpty (4,anArgs) then
begin
f_Login := toString (anArgs [4]);
end;
if isEmpty (Login) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_LOGIN);
{ øåñòîé ïàðàìåòð - ïàðîëü ê smtp-ñåðâåðó }
f_Password := '';
if notEmpty (5,anArgs) then
begin
f_Password := toString (anArgs [5]);
end;
{ ñåäüìîé ïàðàìåòð - AutoTLS }
f_AutoTLS := FALSE;
if notEmpty (6,anArgs) then
begin
f_AutoTLS := toBoolean (anArgs [6]);
end;
{ âîñüìîé ïàðàìåòð - FullSSL }
f_FullSSL := FALSE;
if notEmpty (7,anArgs) then
begin
f_FullSSL := toBoolean (anArgs [7]);
end;
{ äåâÿòûé ïàðàìåòð - ListView
ëîã ïî÷òû }
f_ListView := NIL;
if notEmpty (8,anArgs) then
begin
OBJ := toObject (anArgs [8]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TsListView) ) then
f_ListView := TsListView (OBJ);
end;
{ äåñÿòûé ïàðàìåòð - Gauge
ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_Gauge := NIL;
if notEmpty (9,anArgs) then
begin
OBJ := toObject (anArgs [9]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TControl) ) then
f_Gauge := TGauge (OBJ);
end;
{ îäèííàäöàòûé ïàðàìåòð - StatusPanel
ïîêàçàòåëü ïðîãðåññà çàãðóçêè }
f_StatusPanel := NIL;
if notEmpty (10,anArgs) then
begin
OBJ := toObject (anArgs [10]);
if ( Assigned (OBJ) and OBJ.InheritsFrom (TStatusPanel) ) then
f_StatusPanel := TStatusPanel (OBJ);
end;
{ äâåíàäöàòûé ïàðàìåòð - âðåìÿ îæèäàíèÿ ms }
f_TimeOut := 120000;
if notEmpty (11,anArgs) then
begin
f_TimeOut := toInteger (anArgs [11]);
end;
if ( TimeOut = 0 ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_TIMEOUT);
{ òðèíàäöàòûé ïàðàìåòð - õîñò proxy-ñåðâåðà }
f_ProxyHost := '';
if notEmpty (12,anArgs) then
begin
f_ProxyHost := toString (anArgs [12]);
end;
if ( ProxyHost <> '' ) and not isIPAddress (ProxyHost) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PROXY_HOST);
{ ÷åòûðíàäöàòûé ïàðàìåòð - ïîðò proxy-ñåðâåðà }
f_ProxyPort := 0;
if notEmpty (13,anArgs) then
begin
f_ProxyPort := toInteger (anArgs [13]);
end;
if ( ProxyPort <= 0 ) and ( ProxyHost <> '' ) then
raise Exception.Create (ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_PROXY_PORT);
{ ïÿòíàäöàòûé ïàðàìåòð - ëîãèí proxy-ñåðâåðà }
f_ProxyLogin := '';
if notEmpty (14,anArgs) then
begin
f_ProxyLogin := toString (anArgs [14]);
end;
{ øåñòíàäöàòûé ïàðàìåòð - ïàðîëü proxy-ñåðâåðà }
f_ProxyPassword := '';
if notEmpty (15,anArgs) then
begin
f_ProxyPassword := toString (anArgs [15]);
end;
{ ñåìíàäöàòûé ïàðàìåòð - ïðîòîêîë proxy-ñåðâåðà }
f_ProxyProtocol := '';
if notEmpty (16,anArgs) then
begin
f_ProxyProtocol := toString (anArgs [16]);
end;
{ ñïèñîê ïàêåòîâ }
f_Packages := NIL;
f_PackageIndex := -1;
{ êëèåíò }
f_SMTP := TSMTPClient.Create ([ Host, Port,
Login, Password,
ProxyHost, ProxyPort,
ProxyLogin, ProxyPassword,
ProxyProtocol,
TimeOut,
AutoTLS, FullSSL ]);
{ âðåìÿ îæèäàíèÿ }
f_IdleTime := -1;
{ ëîã }
f_Log := TItems.Create ([]);
except on E: Exception do
_raise ([ 'Create', ERR_TSMTPPACKAGECLIENTTHREAD_CREATE, E, Exception (FatalException) ],
['{9174C67C-2E79-4342-9563-93F462036A7D}']);
end;
end;
destructor TSMTPPackageClientThread.Destroy;
begin
try
_FillChar ( f_Host, Length (f_Host), $00 );
f_Port := 0;
_FillChar ( f_Login, Length (f_Login), $00 );
_FillChar ( f_Password, Length (f_Password), $00 );
_FillChar ( f_ProxyHost, Length (f_ProxyHost), $00 );
f_ProxyPort := 0;
_FillChar ( f_ProxyLogin, Length (f_ProxyLogin), $00 );
_FillChar ( f_ProxyPassword, Length (f_ProxyPassword), $00 );
FreeAndNil (f_Log);
FreeAndNil (f_SMTP);
if ( ReceiverID <> USER_ID ) and ( ReceiverID <> 0 ) then
FreeAndNil (f_Receiver);
FreeAndNil (f_Packages);
FreeAndNil (f_DB);
inherited Destroy;
except on E: Exception do
_raise ([ 'Destroy', ERR_TSMTPPACKAGECLIENTTHREAD_DESTROY, E, Exception (FatalException) ],
['{4A5A71BA-9338-42E8-B63D-AE0664CC6B07}']);
end;
end;
procedure TSMTPPackageClientThread.Main;
var
Stream : TStream;
begin
try
if Terminated then Exit;
inherited Main;
if not Assigned (Packages) then
try
f_Packages := TPackages.Load (DB,[ _([]),
_([{USER_KEY_HASH}]),
_([Receiver.KeyHash]),
_([USER_ID]),
_([]),
_([PACKAGE_CREATED_STATUS_ID]),
_([ TUser, {TPic,} TMessage, TCategorie, TMetaObject ]) ],
[ _pck_time_stamp_create ]) as TPackages;
MaxProgress := Packages.Count;
Progress := 0;
except
FreeAndNil (f_Packages);
end;
// äåëàåì çäåñü íàìåðåííî çàäåðæêó, ÷òîáû íå ïåðåãðóæàòü ñåòü
// ïðîñòî âîçâðàùàåì óïðàâëåíèå â îñíîâíîé ïîòîê
Sleep (1);
if not Assigned (Packages) or ( Packages.Count <= 0 ) then
Terminate
else if ( PackageIndex >= Packages.Count-1 ) then
Terminate
else
try
{ îæèäàåì }
IdleTime := IdleTime +1;
if ( IdleTime >= TimeOut div 10 ) then
IdleTime := -1
else
Exit;
{ ïîñëå îæèäàíèÿ - îáðàáàòûâàåì ñëåäóþùèé ïàêåò }
PackageIndex := PackageIndex + 1;
{ ïðîãðåññ }
Progress := Progress + 1;
{ çàïèñûâàåì ïàêåò }
if Assigned (Packages.ItemAt [PackageIndex]) then
begin
SMTP.Clear;
{ îòïðàâèòåëü }
SMTP.Sender := Login;
{ ïîëó÷àòåëü }
SMTP.Receivers.Add (Receiver.EMail);
{ òåìà - õýø-êëþ÷ ïàêåòà }
SMTP.Subject := Packages.ItemAt [PackageIndex].KeyHash;
{ òåëî ïàêåòà }
Stream := TMemoryStream.Create;
try
Packages.ItemAt [PackageIndex].SaveToStream (Stream);
SMTP.Data.Position := 0;
WriteStreamL (SMTP.Data,Stream);
finally
FreeAndNil (Stream);
end;
{ îòïðàâëÿåì ïàêåò }
if SMTP.Send then
try
{ ìåíÿåì ñòàòóñ ïàêåòà }
Packages.ItemAt [PackageIndex].IDStatus := PACKAGE_SENDED_STATUS_ID;
Packages.ItemAt [PackageIndex].Save;
{ ïèøåì â ëîã ñòàòóñ ïàêåòà }
WriteLog ( Format ('%s:%d',
[ SMTP.SMTP.Sock.GetLocalSinIP,
SMTP.SMTP.Sock.GetLocalSinPort ]),
Format ('%s:%d',
[ SMTP.SMTP.Sock.GetRemoteSinIP,
SMTP.SMTP.Sock.GetRemoteSinPort ]),
Format (MSG_TSMTPPACKAGE_SENDED_PACKAGE,
[ Packages.ItemAt [PackageIndex].KeyHash ]),
pckSend,
Packages.ItemAt [PackageIndex].PckType.IDExternal,
Packages.ItemAt [PackageIndex].MetaClass.GetClassID );
except on E: Exception do
{ ïèøåì â ëîã ïðè÷èíó îøèáêè }
WriteLog ( Format ('%s:%d',
[ SMTP.SMTP.Sock.GetLocalSinIP,
SMTP.SMTP.Sock.GetLocalSinPort ]),
Format ('%s:%d',
[ SMTP.SMTP.Sock.GetRemoteSinIP,
SMTP.SMTP.Sock.GetRemoteSinPort ]),
Format ('%s : %s',
[ ERR_TSMTPPACKAGECLIENTTHREAD_INVALID_DATA,
E.Message ]),
pckError );
end
else
WriteLog ( Format ('%s:%d',
[ SMTP.SMTP.Sock.GetLocalSinIP,
SMTP.SMTP.Sock.GetLocalSinPort ]),
Format ('%s:%d',
[ SMTP.SMTP.Sock.GetRemoteSinIP,
SMTP.SMTP.Sock.GetRemoteSinPort ]),
Format (MSG_TSMTPPACKAGE_SEND_ERROR,
[ SMTP.SMTP.ResultCode ]),
pckError );
end;
except on Error: Exception do
WriteStatus (Error.Message);
end;
except on E: Exception do
_raise ([ 'Main', ERR_TSMTPPACKAGECLIENTTHREAD_MAIN, E, Exception (FatalException) ],
['{5C2304B4-064F-41E4-B1F4-E62E8A32F063}']);
end;
end;
procedure TSMTPPackageClientThread.Return;
var
Itm : TListItem;
ImageIndex : Integer;
begin
try
inherited Return;
if Assigned (ListView) and Assigned (Log) then
begin
while Log.Count > 0 do
begin
Itm := ListView.Items.Add;
Itm.Caption := PLogRecord (Log.Item [0])^.Caption;
Itm.ImageIndex := PLogRecord (Log.Item [0])^.ImageIndex;
Itm.SubItems.Add ( PLogRecord (Log.Item [0])^.Sender );
Itm.SubItems.Add ( PLogRecord (Log.Item [0])^.Receiver );
Itm.SubItems.Add ( PLogRecord (Log.Item [0])^.Message );
Dispose ( PLogRecord (Log.Item [0]) );
Log.Delete (0);
end;
end;
if Assigned (StatusPanel) and notEmpty (Status) then
begin
StatusPanel.Text := Status;
end;
if Assigned (Gauge) then
begin
Gauge.MinValue := 0;
Gauge.MaxValue := MaxProgress;
Gauge.Progress := Progress;
end;
ProcessMessages;
except on E: Exception do
_raise ([ 'Return', ERR_TSMTPPACKAGECLIENTTHREAD_RETURN, E, Exception (FatalException) ],
['{90BA460C-22DC-441D-869F-EEED8E58F321}']);
end;
end;
procedure TSMTPPackageClientThread.WriteStatus (const aMessage: String);
begin
try
Status := aMessage;
except on E: Exception do
_raise (['WriteStatus',ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_STATUS,E],
['{59A32DEC-8F90-484B-BE3B-1F0865639758}']);
end;
end;
procedure TSMTPPackageClientThread.WriteStatus (const aMessage: String;
aParams: array of const);
begin
try
WriteStatus ( Format (aMessage,aParams) );
except on E: Exception do
_raise (['WriteStatus',ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_STATUS,E],
['{4805A25C-377F-4A7D-A77A-FF54BBDE3152}']);
end;
end;
procedure TSMTPPackageClientThread.WriteLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
const anImageIndex: Integer = pckDefault;
const aPackageType: String = '';
const aMetaClassID: String = '');
var
Rec : PLogRecord;
begin
try
if Assigned (Log) then
begin
Rec := AllocMem ( SizeOf (TLogRecord) + 1 );
Rec^.Caption := _DateTimeToStr (now);
Rec^.ImageIndex := anImageIndex;
Rec^.Sender := aSender;
Rec^.Receiver := aReceiver;
if notEmpty (aMetaClassID) then
Rec^.Message := Format ('%s : %s : %s',[aMetaClassID,aPackageType,aMessage])
else
Rec^.Message := aMessage;
Log.Add (Rec);
end;
except on E: Exception do
_raise (['WriteLog',ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_LOG,E],
['{99585726-2FEB-4526-98C9-E1041206208B}']);
end;
end;
procedure TSMTPPackageClientThread.WriteLog (const aSender: String;
const aReceiver: String;
const aMessage: String;
aParams: array of const;
const anImageIndex: Integer = pckDefault;
const aPackageType: String = '';
const aMetaClassID: String = '');
begin
try
WriteLog ( aSender, aReceiver, Format (aMessage,aParams), anImageIndex, aPackageType, aMetaClassID );
except on E: Exception do
_raise (['WriteLog',ERR_TSMTPPACKAGECLIENTTHREAD_WRITE_LOG,E],
['{80E318A5-1959-423B-A7B9-970A39E738AB}']);
end;
end;
end.