Skip to content

Commit 38b58bf

Browse files
authored
Merge pull request #2 from dliocode/fixed-#1-Memory-Leak
Fixed #1
2 parents 667c42c + da38679 commit 38b58bf

File tree

3 files changed

+82
-32
lines changed

3 files changed

+82
-32
lines changed

samples/Model 1/Model1.delphilsp.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "settings": { "project": "file:///Z%3A/DADOS/Projetos/Github/SendEmail/samples/Model%201/Model1.dpr", "dllname": "dcc32280.dll", "dccOptions": "-$O- -$W+ --no-config -Q -TX.exe -AGenerics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE -DDEBUG;;FRAMEWORK_VCL -E.\\Win32\\Debug -I\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\debug\";\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\release\";C:\\Users\\danil\\Documents\\Embarcadero\\Studio\\22.0\\Imports;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\include\" -LEC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Bpl -LNC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp -NU.\\Win32\\Debug -NSWinapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell; -O\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\release\";C:\\Users\\danil\\Documents\\Embarcadero\\Studio\\22.0\\Imports;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\include\" -R\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\release\";C:\\Users\\danil\\Documents\\Embarcadero\\Studio\\22.0\\Imports;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\include\" -U\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\debug\";\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\lib\\Win32\\release\";C:\\Users\\danil\\Documents\\Embarcadero\\Studio\\22.0\\Imports;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\Imports\";C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp;\"c:\\program files (x86)\\embarcadero\\studio\\22.0\\include\" -V -VN -NBC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\Dcp -NHC:\\Users\\Public\\Documents\\Embarcadero\\Studio\\22.0\\hpp\\Win32 -NO.\\Win32\\Debug -LU" , "projectFiles":[ { "name": "USendEmail", "file": "file:///Z%3A/DADOS/Projetos/Github/SendEmail/samples/Model%201/USendEmail.pas" }, { "name": "SendEmail", "file": "file:///Z%3A/DADOS/Projetos/Github/SendEmail/src/SendEmail.pas" } ] , "includeDCUsInUsesCompletion": true, "browsingPaths": [ "file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/OCX/Servers","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/SOURCE/VCL","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/rtl/common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/SOURCE/RTL/SYS","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/rtl/win","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/rtl/win/winrt","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/ToolsAPI","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/SOURCE/IBX","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Internet","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/SOURCE/PROPERTY%20EDITORS","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/soap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/SOURCE/XML","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Indy10/Core","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Indy10/System","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Indy10/Protocols","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/fmx","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/databinding/components","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/databinding/engine","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/databinding/graph","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/ado","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/cloud","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/datasnap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/dbx","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/dsnap","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/vclctrls","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/datasnap/connectors","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/datasnap/proxygen","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DataExplorer","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/DUnitWizard/Source/Common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/DUnitWizard/Source/Common/dunit","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/Common","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/DUnitProject","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/DUnitWizard/Source/DelphiExperts/DUnitProject/dunit","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/src","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/tests","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Experts","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/indy/abstraction","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/indy/implementation","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/indyimpl","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Property%20Editors/Indy10","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/soap/wsdlimporter","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/Visualizers","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/XMLReporting","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnit/Contrib/XPGen","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/rest","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/firedac","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/tethering","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/DUnitX","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/data/ems","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/rtl/net","file:///c%3A/program%20files%20%28x86%29/embarcadero/studio/22.0/source/FlatBox2D" ] } }

samples/Model 1/Model1.dproj

+71-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<ProjectGuid>{6FFDDB60-7779-468B-A486-CFB53791F74C}</ProjectGuid>
4-
<ProjectVersion>19.1</ProjectVersion>
4+
<ProjectVersion>19.4</ProjectVersion>
55
<FrameworkType>VCL</FrameworkType>
66
<Base>True</Base>
77
<Config Condition="'$(Config)'==''">Debug</Config>
@@ -103,17 +103,17 @@
103103
<FormType>dfm</FormType>
104104
</DCCReference>
105105
<DCCReference Include="..\..\src\SendEmail.pas"/>
106-
<BuildConfiguration Include="Release">
107-
<Key>Cfg_2</Key>
108-
<CfgParent>Base</CfgParent>
109-
</BuildConfiguration>
110106
<BuildConfiguration Include="Base">
111107
<Key>Base</Key>
112108
</BuildConfiguration>
113109
<BuildConfiguration Include="Debug">
114110
<Key>Cfg_1</Key>
115111
<CfgParent>Base</CfgParent>
116112
</BuildConfiguration>
113+
<BuildConfiguration Include="Release">
114+
<Key>Cfg_2</Key>
115+
<CfgParent>Base</CfgParent>
116+
</BuildConfiguration>
117117
</ItemGroup>
118118
<ProjectExtensions>
119119
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
@@ -147,6 +147,16 @@
147147
<Operation>0</Operation>
148148
</Platform>
149149
</DeployClass>
150+
<DeployClass Name="AndroidClasses">
151+
<Platform Name="Android">
152+
<RemoteDir>classes</RemoteDir>
153+
<Operation>64</Operation>
154+
</Platform>
155+
<Platform Name="Android64">
156+
<RemoteDir>classes</RemoteDir>
157+
<Operation>64</Operation>
158+
</Platform>
159+
</DeployClass>
150160
<DeployClass Name="AndroidClassesDexFile">
151161
<Platform Name="Android">
152162
<RemoteDir>classes</RemoteDir>
@@ -275,6 +285,16 @@
275285
<Operation>1</Operation>
276286
</Platform>
277287
</DeployClass>
288+
<DeployClass Name="Android_LauncherIcon192">
289+
<Platform Name="Android">
290+
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
291+
<Operation>1</Operation>
292+
</Platform>
293+
<Platform Name="Android64">
294+
<RemoteDir>res\drawable-xxxhdpi</RemoteDir>
295+
<Operation>1</Operation>
296+
</Platform>
297+
</DeployClass>
278298
<DeployClass Name="Android_LauncherIcon36">
279299
<Platform Name="Android">
280300
<RemoteDir>res\drawable-ldpi</RemoteDir>
@@ -438,6 +458,11 @@
438458
<Operation>1</Operation>
439459
<Extensions>.framework</Extensions>
440460
</Platform>
461+
<Platform Name="OSXARM64">
462+
<RemoteDir>Contents\MacOS</RemoteDir>
463+
<Operation>1</Operation>
464+
<Extensions>.framework</Extensions>
465+
</Platform>
441466
<Platform Name="Win32">
442467
<Operation>0</Operation>
443468
</Platform>
@@ -465,6 +490,11 @@
465490
<Operation>1</Operation>
466491
<Extensions>.dylib</Extensions>
467492
</Platform>
493+
<Platform Name="OSXARM64">
494+
<RemoteDir>Contents\MacOS</RemoteDir>
495+
<Operation>1</Operation>
496+
<Extensions>.dylib</Extensions>
497+
</Platform>
468498
<Platform Name="Win32">
469499
<Operation>0</Operation>
470500
<Extensions>.dll;.bpl</Extensions>
@@ -493,6 +523,11 @@
493523
<Operation>1</Operation>
494524
<Extensions>.dylib</Extensions>
495525
</Platform>
526+
<Platform Name="OSXARM64">
527+
<RemoteDir>Contents\MacOS</RemoteDir>
528+
<Operation>1</Operation>
529+
<Extensions>.dylib</Extensions>
530+
</Platform>
496531
<Platform Name="Win32">
497532
<Operation>0</Operation>
498533
<Extensions>.bpl</Extensions>
@@ -522,6 +557,10 @@
522557
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
523558
<Operation>0</Operation>
524559
</Platform>
560+
<Platform Name="OSXARM64">
561+
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
562+
<Operation>0</Operation>
563+
</Platform>
525564
<Platform Name="Win32">
526565
<Operation>0</Operation>
527566
</Platform>
@@ -795,6 +834,10 @@
795834
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
796835
<Operation>1</Operation>
797836
</Platform>
837+
<Platform Name="OSXARM64">
838+
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
839+
<Operation>1</Operation>
840+
</Platform>
798841
</DeployClass>
799842
<DeployClass Name="ProjectOSXEntitlements">
800843
<Platform Name="OSX32">
@@ -805,6 +848,10 @@
805848
<RemoteDir>..\</RemoteDir>
806849
<Operation>1</Operation>
807850
</Platform>
851+
<Platform Name="OSXARM64">
852+
<RemoteDir>..\</RemoteDir>
853+
<Operation>1</Operation>
854+
</Platform>
808855
</DeployClass>
809856
<DeployClass Name="ProjectOSXInfoPList">
810857
<Platform Name="OSX32">
@@ -815,6 +862,10 @@
815862
<RemoteDir>Contents</RemoteDir>
816863
<Operation>1</Operation>
817864
</Platform>
865+
<Platform Name="OSXARM64">
866+
<RemoteDir>Contents</RemoteDir>
867+
<Operation>1</Operation>
868+
</Platform>
818869
</DeployClass>
819870
<DeployClass Name="ProjectOSXResource">
820871
<Platform Name="OSX32">
@@ -825,6 +876,10 @@
825876
<RemoteDir>Contents\Resources</RemoteDir>
826877
<Operation>1</Operation>
827878
</Platform>
879+
<Platform Name="OSXARM64">
880+
<RemoteDir>Contents\Resources</RemoteDir>
881+
<Operation>1</Operation>
882+
</Platform>
828883
</DeployClass>
829884
<DeployClass Required="true" Name="ProjectOutput">
830885
<Platform Name="Android">
@@ -855,6 +910,10 @@
855910
<RemoteDir>Contents\MacOS</RemoteDir>
856911
<Operation>1</Operation>
857912
</Platform>
913+
<Platform Name="OSXARM64">
914+
<RemoteDir>Contents\MacOS</RemoteDir>
915+
<Operation>1</Operation>
916+
</Platform>
858917
<Platform Name="Win32">
859918
<Operation>0</Operation>
860919
</Platform>
@@ -893,16 +952,17 @@
893952
<Operation>1</Operation>
894953
</Platform>
895954
</DeployClass>
896-
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
897-
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
955+
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
956+
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
898957
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
958+
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
959+
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
899960
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
900-
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
901961
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
902-
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
903962
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
904-
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
905-
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
963+
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
964+
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
965+
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
906966
</Deployment>
907967
</BorlandProject>
908968
<ProjectFileVersion>12</ProjectFileVersion>

src/SendEmail.pas

+10-21
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ constructor TSendEmail.Create;
143143
ConnectTimeout := 60000;
144144
ReadTimeout := 60000;
145145
UseEhlo := True;
146-
HeloName := 'SendEmail';
147146
OnStatus := LogSMTPStatus;
148147
OnWorkBegin := WorkBegin;
149148
OnWork := Work;
@@ -487,23 +486,20 @@ function TSendEmail.Connect: TSendEmail;
487486
Log('Loading DLL');
488487
if not LoadOpenSSLLibrary then
489488
begin
490-
Log('DLL''s not compatible or not found (ssleay32 e libeay32)');
491-
raise Exception.Create('DLL''s not compatible or not found (ssleay32 e libeay32)');
489+
Log(WhichFailedToLoad);
490+
raise Exception.Create(Self.ClassName + ' > ' + WhichFailedToLoad);
492491
end;
493492
Log('Loaded DLL');
494493

495-
with FIdSSLOpenSSL do
496-
begin
497-
if FSSL then
498-
SSLOptions.Method := SslvSSLv23;
494+
if FSSL then
495+
FIdSSLOpenSSL.SSLOptions.Method := SslvSSLv23;
499496

500-
if FTLS then
501-
SSLOptions.Method := SslvTLSv1_2;
497+
if FTLS then
498+
FIdSSLOpenSSL.SSLOptions.Method := SslvTLSv1_2;
502499

503-
Destination := FIdSMTP.Host + ':' + FIdSMTP.Port.ToString;
504-
Host := FIdSMTP.Host;
505-
Port := FIdSMTP.Port;
506-
end;
500+
FIdSSLOpenSSL.Destination := FIdSMTP.Host + ':' + FIdSMTP.Port.ToString;
501+
FIdSSLOpenSSL.Host := FIdSMTP.Host;
502+
FIdSSLOpenSSL.Port := FIdSMTP.Port;
507503

508504
FIdSMTP.IOHandler := FIdSSLOpenSSL;
509505

@@ -515,7 +511,7 @@ function TSendEmail.Connect: TSendEmail;
515511
else
516512
begin
517513
Log('Defining encryption: None');
518-
FIdSMTP.IOHandler := TIdIOHandler.MakeDefaultIOHandler(nil);
514+
FIdSMTP.IOHandler := nil;
519515
FIdSMTP.UseTLS := UtNoTLSSupport;
520516
end;
521517

@@ -703,13 +699,6 @@ function TSendEmail.Disconnect: TSendEmail;
703699
except
704700
Log('Except: Disconnected with error');
705701
end;
706-
707-
if FSSL or FTLS then
708-
begin
709-
Log('UnLoading DLL');
710-
UnLoadOpenSSLLibrary;
711-
Log('UnLoaded DLL');
712-
end;
713702
end;
714703

715704
function TSendEmail.IsConnected: Boolean;

0 commit comments

Comments
 (0)