{"id":374,"date":"2021-12-17T16:10:18","date_gmt":"2021-12-17T16:10:18","guid":{"rendered":"https:\/\/www.aixperts.co.uk\/?p=374"},"modified":"2021-12-29T11:43:28","modified_gmt":"2021-12-29T11:43:28","slug":"adding-a-gmail-account-to-your-mutt","status":"publish","type":"post","link":"https:\/\/www.aixperts.co.uk\/?p=374","title":{"rendered":"Adding a Gmail account to your Mutt"},"content":{"rendered":"\n<p>Adding a Gmail IMAP inbox along-side your local mailbox can be useful to have easy access to both personal and work emails. It took a bit of fiddling around, but the recipe below worked for me.<\/p>\n\n\n\n<p>In your standard .muttrc, at the top, just add these two lines:<\/p>\n\n\n\n<p><code>unset folder<br>unset smtp_url<\/code><br><code>unset use_from<\/code><\/p>\n\n\n\n<p>This ensures your personal setup does not try to contact Gmail after you have used your work profile.<\/p>\n\n\n\n<p>Create a config for your work setup in .mutt\/work.rc. Copy your standard .muttrc over, to get the same setup you are used to, then add the lines below at the top.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p><code>set imap_user = \"your@work.com\"<br>set imap_pass = \"password\"<br>set smtp_url = \"smtp:\/\/your@work.com@smtp.gmail.com:587\/\"<br>set smtp_pass = \"password\"<br>set use_from=yes<br>set from = \"your@work.com\"<br>set realname = \"Your Name\"<br>set folder=\"imaps:\/\/imap.gmail.com:993\"<\/code><br><code>set record=\"~\/mail\/other-sent-mail\"<br>set postponed=\"=Drafts\"<br>set spoolfile=\"+INBOX\"<br>set signature=\"~\/.mutt\/signature.work\"<br><br>bind index G imap-fetch-mail<\/code><\/p>\n<\/div><\/div>\n\n\n\n<p>The <em>bind<\/em> statement allows you to refresh the IMAP mailbox by hitting &#8216;G&#8217;. In your standard .muttrc, set your personal signature file:<\/p>\n\n\n\n<p><code>set signature=\"~\/.mutt\/signature.personal\"<\/code><\/p>\n\n\n\n<p>Now, in both files, set folders and macros to switch between them.<\/p>\n\n\n\n<p><code># Folder hooks<br>mbox-hook 'mailbox' 'source ~\/.muttrc'<br>folder-hook 'imaps:\/\/imap.gmail.com:993' 'source ~\/.mutt\/work.rc'<br>macro index &lt;f2&gt; '&lt;sync-mailbox&gt;&lt;enter-command&gt;source ~\/.mutt.rc&lt;enter&gt;&lt;change-folder&gt;\/var\/mail\/&lt;name&gt;&lt;enter&gt;'<br>macro index &lt;f3&gt; '&lt;sync-mailbox&gt;&lt;enter-command&gt;source ~\/.mutt\/work.rc&lt;enter&gt;&lt;change-folder&gt;imaps:\/\/imap.gmail.com:993&lt;enter&gt;'<\/code><\/p>\n\n\n\n<p>To be honest, I&#8217;m not 100% sure on the mbox-hook line, but nothing is broken, so I have left it like that. With the above lines, you can now hit &lt;f2&gt; and &lt;f3&gt; to switch between mail boxes.<\/p>\n\n\n\n<p>Remember, with Gmail, you both need to enable IMAP and setup 2-factor authentication, or it won&#8217;t work. Then you need to &#8220;Add app password&#8221; to get the password to use in your work.rc configuration.<\/p>\n\n\n\n<p>Have fun!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding a Gmail IMAP inbox along-side your local mailbox can be useful to have easy access to both personal and work emails. It took a bit of fiddling around, but the recipe below worked for me. In your standard .muttrc, &hellip; <a href=\"https:\/\/www.aixperts.co.uk\/?p=374\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[109,110,113,112,108],"class_list":["post-374","post","type-post","status-publish","format-standard","hentry","category-software","tag-gmail","tag-imap","tag-mailboxes","tag-multiple","tag-mutt"],"_links":{"self":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=374"}],"version-history":[{"count":5,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":381,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/374\/revisions\/381"}],"wp:attachment":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}