{"id":13757,"date":"2022-08-27T23:04:04","date_gmt":"2022-08-27T20:04:04","guid":{"rendered":"https:\/\/kifarunix.com\/?p=13757"},"modified":"2024-03-09T20:56:51","modified_gmt":"2024-03-09T17:56:51","slug":"configure-postfix-to-use-gmail-app-passwords","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/configure-postfix-to-use-gmail-app-passwords\/","title":{"rendered":"Configure Postfix to Use Gmail App Passwords"},"content":{"rendered":"\n<p>Follow through this tutorial to learn how to configure Postfix to use Gmail App Passwords. Previously, Gmail would allow you to use &#8220;<em>third-party apps or devices which ask you to sign in to your Google Account using only your username and password<\/em>&#8220;. For example, if you were configuring Postfix to use Gmail SMTP relay, then you may need to turn on <a href=\"https:\/\/myaccount.google.com\/lesssecureapps\" target=\"_blank\" rel=\"noreferrer noopener\">Less Secure App Access<\/a> so that the username\/password authentication may work. However, this flexibility come to an end as &nbsp;from&nbsp;<strong>May 30, 2022<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#configure-postfix-to-use-gmail-app-passwords\">Configure Postfix to Use Gmail App Passwords<\/a><ul><li><a href=\"#1-login-to-your-google-account\">1. Login to your Google Account<\/a><\/li><li><a href=\"#2-enable-2-step-verification\">2. Enable 2-Step Verification<\/a><\/li><li><a href=\"#3-create-app-passwords\">3. Create App Passwords<\/a><\/li><li><a href=\"#4-install-gmail-account-app-password-on-postfix\">4. Install Gmail Account App Password on Postfix<\/a><\/li><li><a href=\"#5-restart-postfix-service\">5. Restart Postfix Service<\/a><\/li><li><a href=\"#6-test-postfix-email-relay-via-gmail-smtp\">6. Test Postfix Email Relay via Gmail SMTP<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-postfix-to-use-gmail-app-passwords\">Configure Postfix to Use Gmail App Passwords<\/h2>\n\n\n\n<p>So, how can you configure Postfix to use Gmail SMTP relay after less secure app access is disabled? Google, as a result of disabling less secure app access, recommends the use of <a href=\"https:\/\/support.google.com\/accounts\/answer\/6010255?hl=en#more-secure-apps-how\" target=\"_blank\" rel=\"noreferrer noopener\">more secure apps<\/a> with your account.<\/p>\n\n\n\n<p>Therefore, as an alternative to the use of less secure apps with Postfix Gmail SMPT relay configuration, Postfix can be configured to use Gmail App Passwords (Please also note that Gmail do not recommend the use of App password<strong>, &#8220;<em>App Passwords aren\u2019t recommended and are unnecessary in most cases. To help keep your account secure, use &#8220;Sign in with Google&#8221; to connect apps to your Google Account<\/em>&#8220;)<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-login-to-your-google-account\">1. Login to your Google Account<\/h3>\n\n\n\n<p>Login to your <a href=\"https:\/\/myaccount.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gmail account<\/a> that you want to use with Postfix for relay.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-enable-2-step-verification\">2. Enable 2-Step Verification<\/h3>\n\n\n\n<p>If not already enabled, navigate to <a href=\"https:\/\/myaccount.google.com\/security\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Security<\/strong> section<\/a> &gt; <strong>Signing in to Google<\/strong> and enable 2-Step verification for your account.<\/p>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-account-security.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1485\" height=\"583\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-account-security.png\" alt=\"configure Postfix to use Gmail App Passwords\" class=\"wp-image-13760\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-account-security.png?v=1661630286 1485w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-account-security-768x302.png?v=1661630286 768w\" sizes=\"(max-width: 1485px) 100vw, 1485px\" \/><\/figure><\/a><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on 2-Step Verification &gt; Get Started.<\/li>\n\n\n\n<li>You will be prompted to enter your account password to confirm that the account is actually yours, -:).<\/li>\n\n\n\n<li>Continue to add your phone number and click SEND to get the verification code.<\/li>\n\n\n\n<li>Enter the code that you receive on your phone number to confirm that 2-Step verification works.<\/li>\n\n\n\n<li>Once done, click <strong>TURN ON<\/strong> to enable 2-Step Verification on your account.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-create-app-passwords\">3. Create App Passwords<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Next, go back to <a href=\"https:\/\/myaccount.google.com\/security\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Security<\/strong> section<\/a> &gt; <strong>Signing in to Google<\/strong>. Just below the 2-Step Verification option is App Passwords setting.<\/li>\n\n\n\n<li>Seems the app password option is no longer available as an option. But you can access it directly using  via <a href=\"https:\/\/myaccount.google.com\/apppasswords\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/myaccount.google.com\/apppasswords<\/a>.<\/li>\n<\/ul>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-setting.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1609\" height=\"526\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-setting.png\" alt=\"configure Postfix to use Gmail App Passwords\" class=\"wp-image-13761\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-setting.png?v=1661630353 1609w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-setting-768x251.png?v=1661630353 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-setting-1536x502.png?v=1661630353 1536w\" sizes=\"(max-width: 1609px) 100vw, 1609px\" \/><\/figure><\/a><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click App Passwords to create and use app passwords.<\/li>\n\n\n\n<li>If prompted, enter your account password. You will then proceed to App Passwords settings page.<\/li>\n\n\n\n<li>Select your specific app from the available list. If using <strong>Postfix<\/strong>, then you can select <strong>Other <em>(Custom name)<\/em><\/strong><\/li>\n\n\n\n<li>Enter the name of the App, e.g <strong>Posfix<\/strong> and click <strong>GENERATE<\/strong> to create App password.<\/li>\n<\/ul>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/create-app-password.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1613\" height=\"631\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/create-app-password.png\" alt=\"configure Postfix to use Gmail App Passwords\" class=\"wp-image-13762\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/create-app-password.png?v=1661630388 1613w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/create-app-password-768x300.png?v=1661630388 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/create-app-password-1536x601.png?v=1661630388 1536w\" sizes=\"(max-width: 1613px) 100vw, 1613px\" \/><\/figure><\/a><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Copy the 16-character password and click <strong>DONE<\/strong>.<\/li>\n<\/ul>\n\n\n\n<div><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password.png\" class=\"td-modal-image\"><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1084\" height=\"755\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password.png\" alt=\"configure Postfix to use Gmail App Passwords\" class=\"wp-image-13763\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password.png?v=1661630411 1084w, https:\/\/kifarunix.com\/wp-content\/uploads\/2022\/08\/gmail-app-password-768x535.png?v=1661630411 768w\" sizes=\"(max-width: 1084px) 100vw, 1084px\" \/><\/figure><\/a><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This is the password that you will use for your account on Postfix.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-install-gmail-account-app-password-on-postfix\">4. Install Gmail Account App Password on Postfix<\/h3>\n\n\n\n<p>Next, edit the Postfix SMTP SASL credentials and replace the password with the 16-character password created above.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vim \/etc\/postfix\/sasl_passwd<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;smtp.gmail.com]:587 userid@gmail.com:<strong>ixxxxxxxxxxxxxxd<\/strong><\/code><\/pre>\n\n\n\n<p>Replace the&nbsp;<code><strong>userid@gmail<\/strong><\/code>&nbsp;and&nbsp;<code><strong>password<\/strong><\/code> accordingly.<\/p>\n\n\n\n<p>Save and exit the file.<\/p>\n\n\n\n<p>Regenerate SASL password DB file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>postmap \/etc\/postfix\/sasl_passwd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-restart-postfix-service\">5. Restart Postfix Service<\/h3>\n\n\n\n<p>Once that is done, run Postfix configuration check;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postfix check<\/code><\/pre>\n\n\n\n<p>If there is any error, then the command will print it to standard output. Otherwise it exits with no output and exit status of 0.<\/p>\n\n\n\n<p>Then restart it;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart postfix<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-test-postfix-email-relay-via-gmail-smtp\">6. Test Postfix Email Relay via Gmail SMTP<\/h3>\n\n\n\n<p>You can now test if all is okay as follows;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"Test Postfix Gmail SMTP Relay\" | mail -s \"Postfix Gmail SMTP Relay\" userid@gmail.com<\/code><\/pre>\n\n\n\n<p>You can tail the logs to check the delivery status;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tail \/var\/log\/mail.log<\/code><\/pre>\n\n\n\n<p>Sample output;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\nAug 27 22:42:10 debian11 postfix\/pickup[14560]: 2EAFD653BB: uid=0 from=&lt;root@node01.kifarunix-demo.com>\nAug 27 22:42:10 debian11 postfix\/cleanup[14579]: 2EAFD653BB: message-id=&lt;20220827194210.2EAFD653BB@kifarunix-demo.com>\nAug 27 22:42:10 debian11 postfix\/qmgr[14561]: 2EAFD653BB: from=&lt;root@node01.kifarunix-demo.com>, size=371, nrcpt=1 (queue active)\nAug 27 22:42:12 debian11 postfix\/smtp[14581]: 2EAFD653BB: to=&lt;username@gmail.com>, relay=smtp.gmail.com[142.250.147.109]:587, delay=2.8, delays=0.02\/0.02\/2\/0.78, dsn=2.0.0, <strong>status=sent (250 2.0.0 OK<\/strong>  1661629332 14-20020a170906308e00b0073bdb2f6f28sm2340234ejv.217 - gsmtp)\nAug 27 22:42:12 debian11 postfix\/qmgr[14561]: 2EAFD653BB: removed\n...\n<\/code><\/pre>\n\n\n\n<p>And that is how you can Postfix can be configured to use Gmail App Passwords instead of the now deprecated less secure app access option.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-postfix-to-use-gmail-smtp-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Postfix to Use Gmail SMTP on CentOS 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-postfix-to-use-gmail-smtp-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Postfix to Use Gmail SMTP on Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-postfix-as-send-only-smtp-server-on-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Postfix as Send-Only SMTP Server on Fedora 29<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-postfix-to-use-gmail-smtp-on-ubuntu-20-04\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Postfix to Use Gmail SMTP on Ubuntu 20.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Follow through this tutorial to learn how to configure Postfix to use Gmail App Passwords. Previously, Gmail would allow you to use &#8220;third-party apps or<\/p>\n","protected":false},"author":1,"featured_media":13765,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121],"tags":[5700,5699,5701,5703,5702,5704],"class_list":["post-13757","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-alternative-to-google-less-secure-app-access","tag-configure-postfix-to-use-gmail-app-passwords","tag-deprecated-less-secure-app-access-gmail","tag-gmail-app-password","tag-gmail-third-party-app-access","tag-setup-gmail-app-password","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13757"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=13757"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13757\/revisions"}],"predecessor-version":[{"id":20601,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13757\/revisions\/20601"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/13765"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=13757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=13757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=13757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}