<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mutt &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/tag/mutt/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Sun, 04 Jun 2023 06:41:48 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>mutt integration with Gmail using OAuth</title>
		<link>https://luxing.im/mutt-integration-with-gmail-using-oauth/</link>
					<comments>https://luxing.im/mutt-integration-with-gmail-using-oauth/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Tue, 30 Jul 2019 15:15:41 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[terminal]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=813</guid>

					<description><![CDATA[As I mentioned before, I am a heavy terminal user, including viewing and replying emails with it. Mutt is my email client. Once you have setup your 2 factor authentication with Google, you won&#8217;t be able to access your Gmail using IMAP with your password, you&#8217;ll have to generate a specific password for the so &#8230; <p class="link-more"><a href="https://luxing.im/mutt-integration-with-gmail-using-oauth/" class="more-link">Continue reading<span class="screen-reader-text"> "mutt integration with Gmail using OAuth"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>As I <a href="https://luxing.im/using-mutt-as-email-client/">mentioned</a> before, I am a heavy terminal user, including viewing and replying emails with it. Mutt is my email client. Once you have setup your 2 factor authentication with Google, you won&#8217;t be able to access your Gmail using IMAP with your password, you&#8217;ll have to generate a specific password for the so called <a href="https://support.google.com/a/answer/6260879">&#8220;Less Secure Apps&#8221;</a>. There is a problem with that, if you use IMAP with less-secure-app password on your company account where &#8220;less secure app&#8221; is not allowed, you are probably stuck.</p>
<p>In this tutorial, I am going to show you how to setup the Google recommended OAuth 2.0 way with Mutt.</p>
<p><span id="more-813"></span></p>
<p>Remember, the OAuth client setup should be an one-time step, it should be usable for your different email addresses on Gmail, that includes your work email if your employer choose Gmail as their email service provider, as long as you authorize permission during the OAuth App.</p>
<ol>
<li>Login to your google account, navigate to https://console.cloud.google.com/apis/credentials and if this page says anything API not enabled, enable it.</li>
<li>In the credentials page, create a project.</li>
<li>After creating the project, you should be able to go to the OAuth consent screen tab, put something recognizable in the application name, click save.</li>
<li>Go back to &#8220;Credentials&#8221; page and click on &#8220;Create credentials&#8221; button and select OAuth client ID.</li>
<li>Select other and click create. You&#8217;ll be given an OAuth client ID and secret. You can view the id and secret anytime.</li>
</ol>
<p>Now you&#8217;ve setup an OAuth client, it is time for mutt configuration.</p>
<p>Download oauth2.py from GitLab: <a href="https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py" rel="noopener noreferrer" target="_blank">https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py</a> and make it executable. You&#8217;ll need to run the command to generate an OAuth token.</p>
<p>Fill your Google App client id and secret here: <a href="https://gitlab.com/muttmua/mutt/-/blob/5347d1c5c0f529ad7e1464ce9f1716d54ed9c31a/contrib/mutt_oauth2.py#L61" rel="noopener" target="_blank">https://gitlab.com/muttmua/mutt/-/blob/5347d1c5c0f529ad7e1464ce9f1716d54ed9c31a/contrib/mutt_oauth2.py#L61</a> and Line 62.</p>
<p>Execute the following command to authorize yourself.</p>
<pre>
mutt_oauth2.py userid@myschool.edu.tokens --verbose --authorize
</pre>
<p>Open the web browser with the link given and authenticate yourself, login and grant permission.</p>
<p>The way I manage my files under <code>~/.mutt</code>:</p>
<pre>
.
|-- accounts
|   |-- gmail.asc
|   |-- account2.asc
|   |-- account3.asc
|-- mailcap
|-- muttrc
|-- oauth2.py
...
</pre>
<p>The muttrc master config file only manage generic stuff such as header and format stuff, it also has some macro to map function keys to switch accounts. The actual accounts are under <code>~/.mutt/accounts</code> folder with GPG encryption in ASCII.</p>
<p>The original gmail file should only contain account related stuff, such as IMAP and SMTP configuration. At the core the login lines should be:</p>
<pre>
set imap_user = "your@gmail.com" 
set imap_authenticators="oauthbearer"
set imap_oauth_refresh_command="~/.mutt/mutt_oauth2.py ~/.mutt/tokens/gmail"
set smtp_authenticators="oauthbearer"
set smtp_oauth_refresh_command="~/.mutt/mutt_oauth2.py ~/.mutt/tokens/gmail"
set smtp_url = "smtp://your@gmail.com@smtp.gmail.com:587/"
set from = "your@gmail.com" 
set realname = "Your Name"
set signature = "~/.mutt/signatures/mysig"

# Basic config, you can leave this as is 
set folder = "imaps://imap.gmail.com"
set spoolfile = "+INBOX"
set imap_check_subscribed 
set postponed = "+[Gmail]/Draft"
set record = ""
set header_cache=~/.mutt/cache/headers
</pre>
<p>You should be able to use mutt to view/send emails via Gmail using OAuth 2.0!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/mutt-integration-with-gmail-using-oauth/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">813</post-id>	</item>
		<item>
		<title>Using Mutt as Email client</title>
		<link>https://luxing.im/using-mutt-as-email-client/</link>
					<comments>https://luxing.im/using-mutt-as-email-client/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Fri, 04 Oct 2013 01:00:08 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mutt]]></category>
		<guid isPermaLink="false">http://blog.luxing.im/?p=15</guid>

					<description><![CDATA[I&#8217;ve always fascinated with my professor Jim Diamond&#8217;s email client, and how it interacts with his zsh. Start from today, I am going to change my main email client from Thunderbird to Mutt too. Here is a small piece of snippet that I put into my ~/.mutt configuration. You may follow my steps and copy &#8230; <p class="link-more"><a href="https://luxing.im/using-mutt-as-email-client/" class="more-link">Continue reading<span class="screen-reader-text"> "Using Mutt as Email client"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve always fascinated with my professor Jim Diamond&#8217;s email client, and how it interacts with his <em>zsh</em>. Start from today, I am going to change my main email client from Thunderbird to Mutt too. Here is a small piece of snippet that I put into my ~/.mutt configuration. You may follow my steps and copy the necessary information to your mutt configuration files.</p>
<p><span id="more-15"></span></p>
<p>It is nearly a year that I haven&#8217;t used Windows as my in-production OS, instead I&#8217;ve used either RedHat sponsored Linux distro (Fedora) or a RHEL-copy CentOS.</p>
<pre>sudo yum install mutt</pre>
<p>Now it is the fun part.</p>
<p>By default, your mutt will read info from ~/.muttrc or ~/.mutt/muttrc. Since I have several email addresses needed to be setup, I use the second one.</p>
<pre>mkdir -p ~/.muttrc/accounts</pre>
<p>Which creates requested folders.</p>
<p>Go to ~/.mutt/accounts/ and create your email account file (you may name it as your like, but keep track of the file name) like the following way:</p>
<pre># Uni Email Setting, file name: university
set from = "abcdef@esp.tld"
set realname = "Your Name Here"
# IMAP settings here
set imap_user = "abcdef"
set imap_pass = ""       # Password is empty here so you'll key-in passwords everytime you wish to access your email account
set folder = "imaps://imap.mail.tld:993"
set spoolfile = "imaps://imap.mail.tld:993/Inbox"   # For gmail users, you need to set your spoolfiles to "+INBOX"
set imap_check_subscribed
set mime_forward=yes
set mime_forward_rest=yes

#SMTP settings
set smtp_url = "smtp://abcdef@smtp.esp.tld:587/"
set smtp_pass = ""

set mail_check = 120
set timeout = 300
set imap_keepalive = 300
# You can set the postponed/record to "+Drafts" or "Sent" correspondently below.
set postponed = "imaps://imap.mail.tld:993/Inbox.Drafts"
set record = "imaps://imap.mail.tld:993/Inbox.Sent"
set header_cache=~/.mutt/cache/headers</pre>
<p>You can also put your GnuPG keys under your account if you have multiple keys for multiple emails for some reason. You need to copy the <a href="http://dev.mutt.org/trac/wiki/MuttGuide/UseGPG" target="_blank">content</a> over under each of your account setting. Remember to substitute your public key identifier in the config files.</p>
<p>You can create similar ones with gmail, assume that you have read the comments above.</p>
<p>Now we put some general information into our muttrc:</p>
<pre>vim ~/.mutt/muttrc</pre>
<pre>set editor = "vim"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
alternative_order text/plain text/html *
auto_view text/html
bind editor  complete-query
bind editor ^T complete
bind editor  noop
set hostname = desktop.luxing.im
set sig_on_top = yes

# Create a statusbar shows the information in localtime.
set pager_format="%4C %Z %[!%b %e at %I:%M %p]  %.20n -- %s%* -- (%P)"

# Accounts and Shortcuts
source ~/.mutt/accounts/acadia
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/accounts/yeah<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/accounts/126<enter><change-folder>!<enter>'


# move spam to Spam/ from: http://chrisjrob.com/2011/03/23/configuring-mutt-for-spam/
macro index S "<tag-prefix><enter-command>unset resolve<enter><tag-prefix>N<tag-prefix><enter-command>set resolve<enter><tag-prefix><save-message>=INBOX.Spam<enter>" "file as Spam"
macro pager S "<save-message>=INBOX.Spam<enter>" "file as Spam"

macro index H "<tag-prefix><enter-command>unset resolve<enter><tag-prefix>N<tag-prefix><enter-command>set resolve<enter><tag-prefix><save-message>=INBOX<enter>" "file as Ham"
macro pager H "<save-message>=INBOX<enter>" "file as Ham"

# return to inbox by pressing .
macro index . "<change-folder>=INBOX<enter>" "Inbox"

set pager_format="%4C %Z %[!%b %e at %I:%M %p]  %.20n  %s%* -- (%P)" # show the corresponding local time of the email.
set pgp_use_gpg_agent = yes

</pre>
<p>You need to adjust your accounts corresponding to your settings.</p>
<p>If you put sensitive information like your passwords into your <em>account</em>, remember to chmod 600 for security concern.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/using-mutt-as-email-client/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">15</post-id>	</item>
	</channel>
</rss>
