diff --git a/IMAPClient/.vs/IMAPClient/v16/.suo b/IMAPClient/.vs/IMAPClient/v16/.suo
new file mode 100644
index 0000000000000000000000000000000000000000..9925ffbd5866e5a6cf36f730c6b75f1092f4c851
Binary files /dev/null and b/IMAPClient/.vs/IMAPClient/v16/.suo differ
diff --git a/IMAPClient/IMAPClient.sln b/IMAPClient/IMAPClient.sln
new file mode 100644
index 0000000000000000000000000000000000000000..53c9af074bb06d8f21cab142add8be9311525467
--- /dev/null
+++ b/IMAPClient/IMAPClient.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31205.134
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IMAPClient", "IMAPClient\IMAPClient.csproj", "{97AE5325-877B-4E91-AE3B-E254496E9BA7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{97AE5325-877B-4E91-AE3B-E254496E9BA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{97AE5325-877B-4E91-AE3B-E254496E9BA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{97AE5325-877B-4E91-AE3B-E254496E9BA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{97AE5325-877B-4E91-AE3B-E254496E9BA7}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {CEE76C37-BAA7-4A14-9C46-004F819B7F12}
+	EndGlobalSection
+EndGlobal
diff --git a/IMAPClient/IMAPClient/IMAPClient.csproj b/IMAPClient/IMAPClient/IMAPClient.csproj
new file mode 100644
index 0000000000000000000000000000000000000000..c73e0d1692ab38cc8596bbd32ae080d903aaa778
--- /dev/null
+++ b/IMAPClient/IMAPClient/IMAPClient.csproj
@@ -0,0 +1,8 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+  </PropertyGroup>
+
+</Project>
diff --git a/IMAPClient/IMAPClient/Program.cs b/IMAPClient/IMAPClient/Program.cs
new file mode 100644
index 0000000000000000000000000000000000000000..36fced9df2b68e553b2ca09c86d6a9a11849fd39
--- /dev/null
+++ b/IMAPClient/IMAPClient/Program.cs
@@ -0,0 +1,30 @@
+using System;
+using System.IO;
+using System.Net.Sockets;
+
+namespace IMAPClient
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+            try
+            {
+                socket.Connect("localhost", 143);
+            }
+            catch (Exception ex)
+            {
+                Console.Write("Virhe: " + ex.Message);
+                Console.ReadKey();
+                return;
+            }
+
+            NetworkStream ns = new NetworkStream(socket);
+
+            StreamReader sr = new StreamReader(ns);
+            StreamWriter sw = new StreamWriter(ns);
+
+        }
+    }
+}
diff --git a/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
new file mode 100644
index 0000000000000000000000000000000000000000..ad8dfe1a6310302587a2d0c0111d81b250eb4105
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
@@ -0,0 +1,4 @@
+// <autogenerated />
+using System;
+using System.Reflection;
+[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v3.1", FrameworkDisplayName = "")]
diff --git a/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfo.cs b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfo.cs
new file mode 100644
index 0000000000000000000000000000000000000000..cc0d00730c0b0b6f29f57d276bced5917562f919
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfo.cs
@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+using System;
+using System.Reflection;
+
+[assembly: System.Reflection.AssemblyCompanyAttribute("IMAPClient")]
+[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
+[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
+[assembly: System.Reflection.AssemblyProductAttribute("IMAPClient")]
+[assembly: System.Reflection.AssemblyTitleAttribute("IMAPClient")]
+[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
+
+// Generated by the MSBuild WriteCodeFragment class.
+
diff --git a/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfoInputs.cache b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfoInputs.cache
new file mode 100644
index 0000000000000000000000000000000000000000..9f8bb4430ffb30239a38698bc9e0515f55b0cb84
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.AssemblyInfoInputs.cache
@@ -0,0 +1 @@
+b4ae9b71d5ffeed2eef222b5bf22f846251f60cd
diff --git a/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.assets.cache b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.assets.cache
new file mode 100644
index 0000000000000000000000000000000000000000..c113355ded1cd613bb684503104d3faa1a66da21
Binary files /dev/null and b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.assets.cache differ
diff --git a/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.csprojAssemblyReference.cache b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.csprojAssemblyReference.cache
new file mode 100644
index 0000000000000000000000000000000000000000..74fe67b1ca671095970d4a7fbcae2417231e8f41
Binary files /dev/null and b/IMAPClient/IMAPClient/obj/Debug/netcoreapp3.1/IMAPClient.csprojAssemblyReference.cache differ
diff --git a/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.dgspec.json b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.dgspec.json
new file mode 100644
index 0000000000000000000000000000000000000000..b2455f4d93a2895781a7e495f117379d98da73fc
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.dgspec.json
@@ -0,0 +1,62 @@
+{
+  "format": 1,
+  "restore": {
+    "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj": {}
+  },
+  "projects": {
+    "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj": {
+      "version": "1.0.0",
+      "restore": {
+        "projectUniqueName": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj",
+        "projectName": "IMAPClient",
+        "projectPath": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj",
+        "packagesPath": "C:\\Users\\Joppe\\.nuget\\packages\\",
+        "outputPath": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\obj\\",
+        "projectStyle": "PackageReference",
+        "configFilePaths": [
+          "C:\\Users\\Joppe\\AppData\\Roaming\\NuGet\\NuGet.Config",
+          "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
+        ],
+        "originalTargetFrameworks": [
+          "netcoreapp3.1"
+        ],
+        "sources": {
+          "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
+          "https://api.nuget.org/v3/index.json": {}
+        },
+        "frameworks": {
+          "netcoreapp3.1": {
+            "targetAlias": "netcoreapp3.1",
+            "projectReferences": {}
+          }
+        },
+        "warningProperties": {
+          "warnAsError": [
+            "NU1605"
+          ]
+        }
+      },
+      "frameworks": {
+        "netcoreapp3.1": {
+          "targetAlias": "netcoreapp3.1",
+          "imports": [
+            "net461",
+            "net462",
+            "net47",
+            "net471",
+            "net472",
+            "net48"
+          ],
+          "assetTargetFallback": true,
+          "warn": true,
+          "frameworkReferences": {
+            "Microsoft.NETCore.App": {
+              "privateAssets": "all"
+            }
+          },
+          "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.202\\RuntimeIdentifierGraph.json"
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.props b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.props
new file mode 100644
index 0000000000000000000000000000000000000000..84f1eb192295b24b36bd8e55d6e1a138089562da
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.props
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
+    <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
+    <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
+    <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
+    <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
+    <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Joppe\.nuget\packages\</NuGetPackageFolders>
+    <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
+    <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.9.1</NuGetToolVersion>
+  </PropertyGroup>
+  <ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
+    <SourceRoot Include="C:\Users\Joppe\.nuget\packages\" />
+  </ItemGroup>
+  <PropertyGroup>
+    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.targets b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.targets
new file mode 100644
index 0000000000000000000000000000000000000000..53cfaa19b16f3769b2bfc33db3b5c0053c16fdba
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/IMAPClient.csproj.nuget.g.targets
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8" standalone="no"?>
+<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/IMAPClient/IMAPClient/obj/project.assets.json b/IMAPClient/IMAPClient/obj/project.assets.json
new file mode 100644
index 0000000000000000000000000000000000000000..691159f1f9fcb37f95fa2e8bbc48d8550af6179d
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/project.assets.json
@@ -0,0 +1,67 @@
+{
+  "version": 3,
+  "targets": {
+    ".NETCoreApp,Version=v3.1": {}
+  },
+  "libraries": {},
+  "projectFileDependencyGroups": {
+    ".NETCoreApp,Version=v3.1": []
+  },
+  "packageFolders": {
+    "C:\\Users\\Joppe\\.nuget\\packages\\": {}
+  },
+  "project": {
+    "version": "1.0.0",
+    "restore": {
+      "projectUniqueName": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj",
+      "projectName": "IMAPClient",
+      "projectPath": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj",
+      "packagesPath": "C:\\Users\\Joppe\\.nuget\\packages\\",
+      "outputPath": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\obj\\",
+      "projectStyle": "PackageReference",
+      "configFilePaths": [
+        "C:\\Users\\Joppe\\AppData\\Roaming\\NuGet\\NuGet.Config",
+        "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
+      ],
+      "originalTargetFrameworks": [
+        "netcoreapp3.1"
+      ],
+      "sources": {
+        "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
+        "https://api.nuget.org/v3/index.json": {}
+      },
+      "frameworks": {
+        "netcoreapp3.1": {
+          "targetAlias": "netcoreapp3.1",
+          "projectReferences": {}
+        }
+      },
+      "warningProperties": {
+        "warnAsError": [
+          "NU1605"
+        ]
+      }
+    },
+    "frameworks": {
+      "netcoreapp3.1": {
+        "targetAlias": "netcoreapp3.1",
+        "imports": [
+          "net461",
+          "net462",
+          "net47",
+          "net471",
+          "net472",
+          "net48"
+        ],
+        "assetTargetFallback": true,
+        "warn": true,
+        "frameworkReferences": {
+          "Microsoft.NETCore.App": {
+            "privateAssets": "all"
+          }
+        },
+        "runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.202\\RuntimeIdentifierGraph.json"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/IMAPClient/IMAPClient/obj/project.nuget.cache b/IMAPClient/IMAPClient/obj/project.nuget.cache
new file mode 100644
index 0000000000000000000000000000000000000000..fecc90c96ada082812e13579d4120f88d3107796
--- /dev/null
+++ b/IMAPClient/IMAPClient/obj/project.nuget.cache
@@ -0,0 +1,8 @@
+{
+  "version": 2,
+  "dgSpecHash": "I6DWDCG37yZ8pbmkmbgXqr+nHO1uBKQA3+wwAG+I9fUZS7f/MjKEaBOeXITbpJE6BMNzqGMzRiskC7Wativ1pw==",
+  "success": true,
+  "projectFilePath": "E:\\Kurssit\\ties323\\IMAPClient\\IMAPClient\\IMAPClient.csproj",
+  "expectedPackageFiles": [],
+  "logs": []
+}
\ No newline at end of file
diff --git a/POP3Client/.vs/POP3Client/DesignTimeBuild/.dtbcache.v2 b/POP3Client/.vs/POP3Client/DesignTimeBuild/.dtbcache.v2
index ec4d6a7b8eeac58203c4503c00c1a6c93ddb2ff6..56e6c4c7ec8253f42f09e2f58a445e453ae4d986 100644
Binary files a/POP3Client/.vs/POP3Client/DesignTimeBuild/.dtbcache.v2 and b/POP3Client/.vs/POP3Client/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/POP3Client/.vs/POP3Client/v16/.suo b/POP3Client/.vs/POP3Client/v16/.suo
index b8000bde2e69dc6a9a4b1d207dd1b1275bfc1ac3..ec0a646a1044d4896ef7abb3d3efcc515a6e7774 100644
Binary files a/POP3Client/.vs/POP3Client/v16/.suo and b/POP3Client/.vs/POP3Client/v16/.suo differ
diff --git a/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.dll b/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.dll
index 01c74664d36d5826dd457393a4bff0783e8a74ff..98af4ba4cd3438ac89fdb4c223c6e067363b08c3 100644
Binary files a/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.dll and b/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.dll differ
diff --git a/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.pdb b/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.pdb
index 8808a51e37d3d850ffea0495a0c83c0345168e3d..74a1b508f632575641e36da06520e4488122db03 100644
Binary files a/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.pdb and b/POP3Client/POP3Client/bin/Debug/netcoreapp3.1/POP3Client.pdb differ
diff --git a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csproj.FileListAbsolute.txt b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csproj.FileListAbsolute.txt
index 09b4beb220ef257f8d33b75fc688dacadb77f8bf..fdab9182adf79b6f5fdfb08568f8c55bdd1ee633 100644
--- a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csproj.FileListAbsolute.txt
+++ b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csproj.FileListAbsolute.txt
@@ -10,3 +10,4 @@ E:\Kurssit\ties323\POP3Client\POP3Client\obj\Debug\netcoreapp3.1\POP3Client.cspr
 E:\Kurssit\ties323\POP3Client\POP3Client\obj\Debug\netcoreapp3.1\POP3Client.dll
 E:\Kurssit\ties323\POP3Client\POP3Client\obj\Debug\netcoreapp3.1\POP3Client.pdb
 E:\Kurssit\ties323\POP3Client\POP3Client\obj\Debug\netcoreapp3.1\POP3Client.genruntimeconfig.cache
+E:\Kurssit\ties323\POP3Client\POP3Client\obj\Debug\netcoreapp3.1\POP3Client.csprojAssemblyReference.cache
diff --git a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csprojAssemblyReference.cache b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csprojAssemblyReference.cache
new file mode 100644
index 0000000000000000000000000000000000000000..74fe67b1ca671095970d4a7fbcae2417231e8f41
Binary files /dev/null and b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.csprojAssemblyReference.cache differ
diff --git a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.dll b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.dll
index 01c74664d36d5826dd457393a4bff0783e8a74ff..98af4ba4cd3438ac89fdb4c223c6e067363b08c3 100644
Binary files a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.dll and b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.dll differ
diff --git a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.pdb b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.pdb
index 8808a51e37d3d850ffea0495a0c83c0345168e3d..74a1b508f632575641e36da06520e4488122db03 100644
Binary files a/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.pdb and b/POP3Client/POP3Client/obj/Debug/netcoreapp3.1/POP3Client.pdb differ
diff --git a/SMTPServer/.vs/STMPServer/v16/.suo b/SMTPServer/.vs/STMPServer/v16/.suo
index b3ddfd8fb27c60fe59a6055f318c6af2e429529b..4248d48f6188bda5e607fdf68cd1186b28ff9194 100644
Binary files a/SMTPServer/.vs/STMPServer/v16/.suo and b/SMTPServer/.vs/STMPServer/v16/.suo differ
diff --git a/SMTPServer/STMPServer/Program.cs b/SMTPServer/STMPServer/Program.cs
index c876e6a7da1a608027d98036d95e51ac6498f0a9..ab328773d68ebecc8a07b268618e3a1cf62e3e94 100644
--- a/SMTPServer/STMPServer/Program.cs
+++ b/SMTPServer/STMPServer/Program.cs
@@ -2,8 +2,10 @@
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.IO;
+using System.Collections.Generic;
 
 namespace STMPServer
 {
@@ -11,34 +13,48 @@ namespace STMPServer
     {
         static void Main(string[] args)
         {
-            //int[] ports = new int[] { 25000, 110 };
-            int[] ports = new int[] { 25000 }; // testing purposes
-            string[] inbox = new string[1];
+            int[] ports = new int[] { 25000, 110, 143 };
+            
+            List<string> inbox = new List<string>();
 
             for (int i = 0; i < ports.Length; i++)
             {
                 Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                 IPEndPoint iep = new IPEndPoint(IPAddress.Loopback, ports[i]);
                 socket.Bind(iep);
-
-                // Kuinka monta asiakasta saa olla 
                 socket.Listen(1);
+
                 bool while_on = true;
-                string mail;
+                List<string> mails = new List<string>();
+                
                 Console.WriteLine("SMTP Palvelin käynnissä portissa: " + ports[i]);
 
                 while (while_on)
                 {
-                    // Tähän joku timeout ??
-                    mail = HandleSMTPClient(socket);
-                    if(mail != "") { inbox[0] = mail; }
-                    //HandlePOP3Client(socket);
-                }
-                Console.ReadKey();
-                socket.Close();
+                    Task.Run(() => {
+                        
+                        mails = HandleSMTPClient(socket);
+                    });
+
+                    Task.Run(() =>
+                    {
+                        HandlePOP3Client(socket, inbox);
+                    }); 
+
+                    if (mails != null) 
+                        { 
+                            foreach (string mail in mails)
+                            {
+                                inbox.Add(mail);
+                            }
+                        }
+                    }
+                    Console.ReadKey();
+                    socket.Close();
             }
         }
 
+        // This is enum for keeping up with the state of the conversation
         enum POPTila : UInt16
         {
             Aloitus,
@@ -47,14 +63,16 @@ namespace STMPServer
             Update
         }
 
+        // 
         enum AuthState : UInt16
         {
             UserState,
             PassState
         }
 
+        
 
-        static void HandlePOP3Client(Socket socket)
+        private static void HandlePOP3Client(Socket socket, List<string> inbox)
         {
             Socket asiakas = socket.Accept();
             string ip = ((IPEndPoint)(asiakas.RemoteEndPoint)).Address.ToString();
@@ -65,7 +83,6 @@ namespace STMPServer
             AuthState authState = AuthState.UserState;
 
             bool keskustelu = true;
-            string[] viestit = new string[] { "viesti 1", "viesti2", "viestriiii3" };
 
             // 10min timeout jos ei vastaa?
             while(keskustelu)
@@ -92,7 +109,7 @@ namespace STMPServer
                         asiakas.Receive(buffer);
                         asiakas_vastaus = TrimVastaus(Encoding.UTF8.GetString(buffer), asiakas);
 
-                        state = HandleTransaction(asiakas_vastaus, asiakas, viestit);
+                        state = HandleTransaction(asiakas_vastaus, asiakas, inbox);
                         if(state == 1) { tila = POPTila.Update; }
                         break;
                     case POPTila.Update:
@@ -160,7 +177,7 @@ namespace STMPServer
             return change_state;
         }
 
-        static int HandleTransaction(string msg, Socket socket, string[] viestit)
+        static int HandleTransaction(string msg, Socket socket, List<string> viestit)
         {
             string[] array = msg.Split(' ');
             int tila = 0;
@@ -170,24 +187,24 @@ namespace STMPServer
                 if(array.Length > 1)
                 {
                     int num = Int32.Parse(array[1]);
-                    if(num <= viestit.Length)
+                    if(num <= viestit.Count)
                     {
                         string vastaus = string.Format("+OK {0} {1}", num, Encoding.UTF8.GetByteCount(viestit[num - 1]));
                         VastaaAsiakas(vastaus, socket);
                     } else
                     {
-                        string vastaus = string.Format("-ERR no such message, only {0} messages in maildrop", viestit.Length);
+                        string vastaus = string.Format("-ERR no such message, only {0} messages in maildrop", viestit.Count);
                         VastaaAsiakas(vastaus, socket);
                     }
                 } else
                 {
-                    for (int i = 0; i < viestit.Length; i++)
+                    for (int i = 0; i < viestit.Count; i++)
                     {
                         koko += Encoding.UTF8.GetByteCount(viestit[i]);
                     }
-                    string vastaus = string.Format("+OK {0} messages ({1} octets)", viestit.Length, koko);
+                    string vastaus = string.Format("+OK {0} messages ({1} octets)", viestit.Count, koko);
                     VastaaAsiakas(vastaus, socket);
-                    for(int i = 0; i < viestit.Length; i++)
+                    for(int i = 0; i < viestit.Count; i++)
                     {
                         vastaus = "" + (i+1) + " " + Encoding.UTF8.GetByteCount(viestit[i]);
                         VastaaAsiakas(vastaus, socket);
@@ -202,7 +219,7 @@ namespace STMPServer
             return tila;
         }
 
-        static string HandleSMTPClient(Socket socket)
+        private static List<string> HandleSMTPClient(Socket socket)
         {
             Socket asiakas = socket.Accept();
             string ip = ((IPEndPoint)(asiakas.RemoteEndPoint)).Address.ToString();
@@ -212,7 +229,7 @@ namespace STMPServer
             asiakas.Send(Encoding.UTF8.GetBytes("220 TIES323 Postipalvelin\r\n"));
             bool keskustelu = true;
             bool data_vipu = false;
-            string mail = "";
+            List<string> mail = new List<string>();
 
             while (keskustelu)
             {
@@ -228,7 +245,7 @@ namespace STMPServer
                 int tila = 0;
                 if (data_vipu)
                 {
-                    mail = ValidoiData(lines, asiakas);
+                    mail.Add(ValidoiData(lines, asiakas));
                     tila = 0;
                 }
                 else
diff --git a/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.dll b/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.dll
index e117101410faaa0c1bfcbf51b29842900d41aa31..235034225d56fc77201a02f3f835e2295f5250c4 100644
Binary files a/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.dll and b/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.dll differ
diff --git a/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.pdb b/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.pdb
index 2b6ac083e5d73bfe9b47152c1407019e54503571..f843df731a866b567536a0413c11d6ea0fe540fb 100644
Binary files a/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.pdb and b/SMTPServer/STMPServer/bin/Debug/netcoreapp3.1/STMPServer.pdb differ
diff --git a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.csprojAssemblyReference.cache b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.csprojAssemblyReference.cache
index e23245258eaf6b6145a13830bacb66ca8fd7c885..475e9f25ddab19c98e99fb9760c6360cd0369394 100644
Binary files a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.csprojAssemblyReference.cache and b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.csprojAssemblyReference.cache differ
diff --git a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.dll b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.dll
index e117101410faaa0c1bfcbf51b29842900d41aa31..235034225d56fc77201a02f3f835e2295f5250c4 100644
Binary files a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.dll and b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.dll differ
diff --git a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.pdb b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.pdb
index 2b6ac083e5d73bfe9b47152c1407019e54503571..f843df731a866b567536a0413c11d6ea0fe540fb 100644
Binary files a/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.pdb and b/SMTPServer/STMPServer/obj/Debug/netcoreapp3.1/STMPServer.pdb differ