{"id":5552,"date":"2023-07-27T16:45:20","date_gmt":"2023-07-27T14:45:20","guid":{"rendered":"https:\/\/www.limilabs.com\/blog\/?p=5552"},"modified":"2024-05-20T13:08:00","modified_gmt":"2024-05-20T11:08:00","slug":"using-app-passwords-with-gmail","status":"publish","type":"post","link":"https:\/\/www.limilabs.com\/blog\/using-app-passwords-with-gmail","title":{"rendered":"Authenticate using Gmail&#8217;s App Passwords to IMAP, POP3 and SMTP"},"content":{"rendered":"\n<p>An app password is a 16-digit passcode that serves as an alternative authentication method, granting <a href=\"https:\/\/www.limilabs.com\/mail\">Mail.dll .NET IMAP, POP3 or SMTP client<\/a> access to your Gmail Account with the same level of security as using a regular password. <\/p>\n\n\n\n<p>Your primary password can&#8217;t be used to authenticate anymore, because of Gmail&#8217;s secure access policies. Gmail introduced app passwords as a means to enhance account security.<\/p>\n\n\n\n<p>This unique 16-digit passcode acts as a one-time key, eliminating the need to share your primary Google Account password with the application. <\/p>\n\n\n\n<p>By generating an app password, users can rest assured that their sensitive credentials remain protected, and the <a href=\"\/mail\">Mail.dll .NET client<\/a> can seamlessly interact with your Gmail Account, enabling efficient email management without compromising security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">OAuth 2.0 alternative<\/h2>\n\n\n\n<p>In many cases OAuth 2.0 is a better, but more complex option to access IMAP, POP3 and SMTP:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-gmail-imap-web-applications\" title=\"OAuth 2.0 with Gmail over IMAP for web applications\">OAuth 2.0 with Gmail over IMAP for web applications (Google.Apis)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-gmail-imap-installed-applications\" title=\"OAuth 2.0 with Gmail over IMAP for installed applications\">OAuth 2.0 with Gmail over IMAP for installed applications (Google.Apis)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.limilabs.com\/blog\/oauth2-gmail-imap-service-account\" title=\"OAuth 2.0 with Gmail over IMAP for service account\">OAuth 2.0 with Gmail over IMAP for service account (Google.Apis)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Enable 2-Step verification<\/h2>\n\n\n\n<p>Gmail&#8217;s App passwords can only be used with accounts that have&nbsp;<a href=\"https:\/\/support.google.com\/accounts\/answer\/185839\">2-Step Verification<\/a>&nbsp;turned on.<\/p>\n\n\n\n<p>First go to your <a href=\"https:\/\/myaccount.google.com\/\">Google Account<\/a> and on the left navigation panel, choose <strong>Security<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"412\" height=\"501\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/1.png\" alt=\"\" class=\"wp-image-5553\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/1.png 412w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/1-247x300.png 247w\" sizes=\"(max-width: 412px) 100vw, 412px\" \/><\/figure>\n\n\n\n<p>On the <strong>&#8220;Signing in to Google&#8221;<\/strong> panel:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Make sure I that <strong>2-Step Verification is turned on<\/strong> <\/li>\n\n\n\n<li>Finally choose <strong>App Passwords<\/strong> (you may need to scroll down a bit):<\/li>\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"876\" height=\"341\" class=\"size-full wp-image-5554\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/2.png\" alt=\"\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/2.png 876w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/2-300x117.png 300w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/2-768x299.png 768w\" sizes=\"(max-width: 876px) 100vw, 876px\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generate new App password<\/h2>\n\n\n\n<p>On the &#8220;App password&#8221; screen select device and choose the device you&#8217;re using. <\/p>\n\n\n\n<p>Then click <strong>Generate<\/strong> to create a new password:<br><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"411\" class=\"size-full wp-image-5555\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/3.png\" alt=\"\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/3.png 722w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/3-300x171.png 300w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/p>\n\n\n\n<p>New password will be generated &#8211; ready to use with Mail.dll clients. <\/p>\n\n\n\n<p>Remember to <strong>copy <\/strong>the new password, because it won&#8217;t be displayed again:<br><img loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"746\" class=\"size-full wp-image-5556\" src=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/4.png\" alt=\"\" srcset=\"https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/4.png 760w, https:\/\/www.limilabs.com\/blog\/wp-content\/uploads\/2019\/10\/4-300x294.png 300w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><\/p>\n\n\n\n<p>Now you are ready to <strong>log in<\/strong> to your IMAP, SMTP, POP3 account <strong>using your email and the generated password<\/strong> (instead of your email&#8217;s primary password).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Authenticate using IMAP component<\/h2>\n\n\n\n<p><a href=\"\/mail\">Mail.dll .NET email  library<\/a> provides a secure and efficient way to access email accounts, manage and parse email messages. It is a powerful .NET library that simplifies the implementation of IMAP functionality in various .NET applications.<\/p>\n\n\n\n<p>We&#8217;ll use IMAP .NET client in an example below. Note that same password can be used for POP3 .NET client and SMTP .NET clients in exactly the same way.<\/p>\n\n\n\n<p>Remember <strong>not <\/strong>to include any spaces when coping the app password to IMAP client&#8217;s authentication method, because authentication will fail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">C# code:<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing (Imap client = new Imap()) \n{ \n    client.ConnectSSL(\"imap.gmail.com\"); \n    client.UseBestLogin(\"XXXXX@gmail.com\", \"kvrcdzlicajaupje\"); \n\n    \/\/ ... \n\n    client.Close(); \n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\"> VB.NET code:<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: vb; title: ; notranslate\" title=\"\">\nUsing imap As New Imap \n    imap.ConnectSSL(\"imap.gmail.com\") \n    imap.UseBestLogin(\"XXXXX@gmail.com\", \"kvrcdzlicajaupje\") \n\n    ' ... \n\n    imap.Close() \nEnd Using\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Suggested reading<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.limilabs.com\/blog\/receive-unseen-emails-using-imap\" title=\"Receive unseen emails using IMAP\">Receive unseen emails using IMAP<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.limilabs.com\/blog\/save-all-attachments-to-disk-using-imap\" title=\"Save all attachments to disk using IMAP\">Save all attachments to disk using IMAP<\/a><\/li>\n<\/ul>\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>An app password is a 16-digit passcode that serves as an alternative authentication method, granting Mail.dll .NET IMAP, POP3 or SMTP client access to your Gmail Account with the same level of security as using a regular password. Your primary password can&#8217;t be used to authenticate anymore, because of Gmail&#8217;s secure access policies. Gmail introduced [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[119,25,28,50],"class_list":["post-5552","post","type-post","status-publish","format-standard","hentry","category-mail-dll","tag-app-passwords","tag-gmail","tag-imap","tag-smtp"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5552"}],"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=5552"}],"version-history":[{"count":21,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5552\/revisions"}],"predecessor-version":[{"id":6623,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/posts\/5552\/revisions\/6623"}],"wp:attachment":[{"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/media?parent=5552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/categories?post=5552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.limilabs.com\/blog\/wp-json\/wp\/v2\/tags?post=5552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}