{"id":1305,"date":"2010-10-25T15:49:54","date_gmt":"2010-10-25T13:49:54","guid":{"rendered":"http:\/\/www.limilabs.com\/blog\/index.php\/use-ssl-with-pop3"},"modified":"2023-09-22T16:00:48","modified_gmt":"2023-09-22T14:00:48","slug":"use-tls-ssl-with-pop3-net","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/use-tls-ssl-with-pop3-net","title":{"rendered":"Use TLS\/SSL with POP3 in .NET"},"content":{"rendered":"\n<p><a href=\"\/mail\">Mail.dll POP3 .NET email component<\/a> supports Secure Socket Layer (<strong>SSL<\/strong>) and Transport Layer Security (<strong>TLS<\/strong>) protocols to authenticate the server and secure client-server email downloads.<\/p>\n\n\n\n<p>There are two modes in which Mail.dll can work:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Implicit <\/strong>&#8211; where Mail.dll POP3 client immediately connects using secure channel,<\/li>\n\n\n\n<li><strong>Explicit <\/strong>&#8211; where Mail.dll POP3 client connects on unsecured channel first and then secures the communication by issuing STLS command. This mode is sometimes called TLS.<\/li>\n<\/ul>\n\n\n\n<p>In both cases, by default, Secure Sockets Layer (SSL) 3.0 and Transport Layer Security (TLS) 1.0, 1.1, 1.2, 1.3 are acceptable for secure communication. You can change the defaults using <em>Pop3.SSLConfiguration<\/em> property.<\/p>\n\n\n\n<p><em>Pop3<\/em> client may decide to secure the channel, if POP3 server explicitly forbids logging-in on unsecured channel and you are using <em>UseBestLogin<\/em> method.<\/p>\n\n\n\n<div class=\"well\">Here you can find more details on <a href=\"\/blog\/ssl-vs-tls-vs-starttls-stls\">SSL vs TLS vs STARTTLS<\/a>.<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">POP3 implicit TLS\/SSL mode<\/h2>\n\n\n\n<p>Mail.dll POP3 component connects using secure TLS\/SSL channel. You need to know in advance, if the server supports TLS\/SSL connections &#8211; ask your administrator. Typically, POP3 over TLS\/SSL is associated with port 995, but this is not always the case. You can always specify different, then standard port, using <em>ConnectSSL<\/em> method overloads.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ C# version\n\nusing System;\nusing Limilabs.Mail;\nusing Limilabs.Client.POP3;\n\nclass Program\n{\n    static void Main(string&#x5B;] args)\n    {\n        using (Pop3 pop3 = new Pop3())\n        {\n            pop3.ConnectSSL(\"pop.example.com\");\n            pop3.UseBestLogin(\"user\", \"password\");\n\n            MailBuilder builder = new MailBuilder();\n            foreach (string uid in pop3.GetAll())\n            {\n                var eml = pop3.GetMessageByUID(uid);\n                IMail email = builder.CreateFromEml(eml);\n\n                string subject = email.Subject;\n            }\n            pop3.Close();\n        }\n    }\n};\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: vb; title: ; notranslate\" title=\"\">\n' VB.NET version\n\nImports System\nImports Limilabs.Mail\nImports Limilabs.Client.POP3\n\nPublic Module Module1\n    Public Sub Main(ByVal args As String())\n\n        Using pop3 As New Pop3()\n            pop3.ConnectSSL(\"pop.example.com\")\n            pop3.UseBestLogin(\"user\", \"password\")\n\n            Dim builder As New MailBuilder()\n            For Each uid As String In pop3.GetAll()\n                Dim eml = pop3.GetMessageByUID(uid)\n                Dim email As IMail = builder.CreateFromEml(eml)\n\n                Dim subject As String = email.Subject\n            Next\n            pop3.Close()\n        End Using\n\n    End Sub\nEnd Module\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">POP3 explicit TLS\/SSL mode<\/h2>\n\n\n\n<p>Mail.dll POP3 component connects using clear text channel and secures the channel using TLS\/SSL by issuing STLS command. Typically standard POP3 port 110 is used, but this is not always the case. You can always specify different then standard port using <em>Connect<\/em> method overloads.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\n\/\/ C# version\n\nusing System;\nusing Limilabs.Mail;\nusing Limilabs.Client.POP3;\n\nclass Program\n{\n    static void Main(string&#x5B;] args)\n    {\n        using (Pop3 pop3 = new Pop3())\n        {\n            pop3.Connect(\"pop.example.com\");\n\n            pop3.StartTLS();\n\n            pop3.UseBestLogin(\"user\", \"password\");\n\n            MailBuilder builder = new MailBuilder();\n            foreach (string uid in pop3.GetAll())\n            {\n                var eml = pop3.GetMessageByUID(uid);\n                IMail email = builder.CreateFromEml(eml);\n\n                string subject = email.Subject;\n            }\n            pop3.Close();\n        }\n    }\n};\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: vb; title: ; notranslate\" title=\"\">\n' VB.NET version\n\nImports System\nImports Limilabs.Mail\nImports Limilabs.Client.POP3\n\nPublic Module Module1\n    Public Sub Main(ByVal args As String())\n\n        Using pop3 As New Pop3()\n            pop3.Connect(\"pop.example.com\")\n\n            pop3.STLS()\n\n            pop3.UseBestLogin(\"user\", \"password\")\n\n            Dim builder As New MailBuilder()\n            For Each uid As String In pop3.GetAll()\n                Dim eml = pop3.GetMessageByUID(uid)\n                Dim email As IMail = builder.CreateFromEml(eml)\n\n                Dim subject As String = email.Subject\n            Next\n            pop3.Close()\n        End Using\n\n    End Sub\nEnd Module\n<\/pre><\/div>\n\n\n<p>After you connect, you can check, if your POP3 server supports explicit TLS\/SSL using following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/ C# version\n\nbool supportsSTLS = pop3.SupportedExtensions()\n   .Contains(Pop3Extension.STLS);\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n' VB.NET version\n\nDim supportsSTLS As Boolean = pop3.SupportedExtensions() _\n   .Contains(Pop3Extension.STLS)\n<\/pre><\/div>\n\n\n<p>You can read more here on how to know <a href=\"\/blog\/get-supported-server-extensions-imap-pop3-smtp\">which extensions does your server support<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Self-signed certificates<\/h2>\n\n\n\n<p>If you are using self-signed certificates you may encounter this error: <a href=\"\/blog\/the-remote-certificate-is-invalid-according-to-the-validation-procedure\">The remote certificate is invalid according to the validation procedure<\/a>.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<br \/>\n<a class=\"btn btn-primary btn-largest btn-action\" href=\"\/mail\/download\">Get Mail.dll<\/a>\n<br \/>\n","protected":false},"excerpt":{"rendered":"<p>Mail.dll POP3 .NET email component supports Secure Socket Layer (SSL) and Transport Layer Security (TLS) protocols to authenticate the server and secure client-server email downloads. There are two modes in which Mail.dll can work: In both cases, by default, Secure Sockets Layer (SSL) 3.0 and Transport Layer Security (TLS) 1.0, 1.1, 1.2, 1.3 are acceptable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[15,33,42,53,83,57],"class_list":["post-1305","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-c","tag-email-component","tag-pop3","tag-ssl","tag-tls","tag-vb-net"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1305"}],"collection":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/comments?post=1305"}],"version-history":[{"count":21,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1305\/revisions"}],"predecessor-version":[{"id":6589,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/1305\/revisions\/6589"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=1305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=1305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=1305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}