notes/neomutt_config.html
2023-04-06 02:22:42 -07:00

206 lines
No EOL
53 KiB
HTML

<!doctype html><html><head><meta charset=UTF-8><meta content="IE=edge" http-equiv=X-UA-Compatible><meta content="width=device-width,initial-scale=1.0" name=viewport><title>
A Terminal Email Client As An Alternative To Gmail: The Old Dog Neomutt
</title><meta content="A Terminal Email Client As An Alternative To Gmail: The Old Dog Neomutt" property=og:title><link href=https://seniormars.github.io/fonts.css rel=stylesheet><script async data-goatcounter=https://seniormars.goatcounter.com/count src=https://seniormars.github.io/js/count.js></script><noscript><img src="https://seniormars.goatcounter.com//count?p=/posts/neomutt/&t=A Terminal Email Client As An Alternative To Gmail: The Old Dog Neomutt"></noscript><script>MathJax={tex:{inlineMath:[['$','$'],['\\(','\\)']]}}</script><script async id=MathJax-script src=https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js></script><link href=https://seniormars.github.io/atom.xml rel=alternate title=SeniorMars type=application/atom+xml><link href=https://seniormars.github.io/theme/light.css rel=stylesheet><link media="(prefers-color-scheme: dark)" href=https://seniormars.github.io/theme/dark.css rel=stylesheet><link href=https://seniormars.github.io/main.css media=screen rel=stylesheet><body><div class=content><header><div class=main><a href=https://seniormars.github.io>SeniorMars</a><div class=socials><a class=social href=https://github.com/seniormars/ rel=me> <img alt=github src=/social_icons/github.svg> </a><a class=social href=https://www.youtube.com/seniormarstries rel=me> <img alt=youtube src=/social_icons/youtube.svg> </a><a class=social href=/rss.xml rel=me> <img alt=rss src=/social_icons/rss.svg> </a></div></div><nav><a href=/posts style=margin-left:.7em>/posts</a><a href=/projects style=margin-left:.7em>/projects</a><a href=/about style=margin-left:.7em>/about</a><a href=/other style=margin-left:.7em>/other</a></nav></header><main><article><div class=title><div class=page-header>A Terminal Email Client As An Alternative To Gmail: The Old Dog Neomutt<span class=primary-color style=font-size:1.6em>.</span></div><div class=meta>Posted on <time>2023-04-02</time></div></div><h1>Table of Contents</h1><ul><li><a href=https://seniormars.github.io/posts/neomutt/#motivation>Motivation</a><li><a href=https://seniormars.github.io/posts/neomutt/#neomutt>Neomutt</a> <ul><li><a href=https://seniormars.github.io/posts/neomutt/#end-goal>End Goal</a><li><a href=https://seniormars.github.io/posts/neomutt/#introduction-and-why>Introduction and WHY?</a><li><a href=https://seniormars.github.io/posts/neomutt/#installation>Installation</a></li><ul><li><a href=https://seniormars.github.io/posts/neomutt/#macos>macOS</a><li><a href=https://seniormars.github.io/posts/neomutt/#arch-linux>Arch Linux</a><li><a href=https://seniormars.github.io/posts/neomutt/#gentoo>Gentoo</a><li><a href=https://seniormars.github.io/posts/neomutt/#ubuntu-and-wsl2-using-ubuntu>Ubuntu and WSL2 using Ubuntu</a></ul><li><a href=https://seniormars.github.io/posts/neomutt/#running-neomutt-for-the-first-time>Running Neomutt for the first time</a><li><a href=https://seniormars.github.io/posts/neomutt/#initial-mutt-configuration>Initial Mutt Configuration</a></li><ul><li><a href=https://seniormars.github.io/posts/neomutt/#google-gmail-and-app-specific-passwords>Google, Gmail, and App-specific passwords</a><li><a href=https://seniormars.github.io/posts/neomutt/#accessing-gmail-with-neomutt>Accessing Gmail with Neomutt</a></ul><li><a href=https://seniormars.github.io/posts/neomutt/#mailboxes>Mailboxes</a><li><a href=https://seniormars.github.io/posts/neomutt/#settings-i-highly-recommend>Settings I highly recommend</a><li><a href=https://seniormars.github.io/posts/neomutt/#sidebar>Sidebar</a><li><a href=https://seniormars.github.io/posts/neomutt/#signature>Signature</a><li><a href=https://seniormars.github.io/posts/neomutt/#editor>Editor</a></li><ul><li><a href=https://seniormars.github.io/posts/neomutt/#n-vim-and-mail>(N)vim and Mail</a><li><a href=https://seniormars.github.io/posts/neomutt/#keybindings>Keybindings</a></ul><li><a href=https://seniormars.github.io/posts/neomutt/#mailcap>Mailcap</a><li><a href=https://seniormars.github.io/posts/neomutt/#colors>Colors</a><li><a href=https://seniormars.github.io/posts/neomutt/#external-programs>External programs</a></li><ul><li><a href=https://seniormars.github.io/posts/neomutt/#urlscan>Urlscan</a><li><a href=https://seniormars.github.io/posts/neomutt/#query>Query</a><li><a href=https://seniormars.github.io/posts/neomutt/#encrypt>Encrypt</a></ul></ul><li><a href=https://seniormars.github.io/posts/neomutt/#conclusion>Conclusion</a></ul><section class=body><h1 id=motivation>Motivation</h1><p>In this day and age, every university pairs a student's email address with their administered Google suite platform. Typically, for most students, this default saves them a lot of trouble—that is, if you stay within the constraints of what your university considers “normal use”. For instance, if you want to use Google domains, Google cloud's APIs, or customize your Google security options, you are going to have a bad time. Don't get me wrong, I understand why some of these rules are forced upon students, but precisely because they are forced, I believe that there should be leeway for students that wish to opt out of the default settings. Now, this blog post won't teach how to petition your university to rid of Google, but it will teach you how to set up a terminal alternative to Gmail (most notably this blog is for college students that are forced to use Google's email platform).<p>Note:</p><center> This blog assumes basic terminal maturity </center><h1 id=neomutt>Neomutt</h1><h2 id=end-goal>End Goal</h2><p>Before I continue, I would like to show you what the result will look like:<p><img alt=Neomutt src=https://seniormars.github.io/posts/neomutt/neomutt0.png><p>Here is an image with an email open:<p><img alt=Neomutt src=https://seniormars.github.io/posts/neomutt/neomutt1.png><p>Finally, here is an image with a reply open (also <code>s/crack/cracked</code>): <img alt="Neomutt reply" src=https://seniormars.github.io/posts/neomutt/reply.png><p>At the end of this blog, I'll show the configuration we came up with.<h2 id=introduction-and-why>Introduction and WHY?</h2><p>Ok, you have seen the images, but now you wonder: 1) what am I looking at? And 2) why would I want to use this? Let's start with the first question. These images are of a terminal email client called Neomutt and it is my go-to email client. It supports all the basic email features that you would expect from an email client, plus way more! The second question is a bit more complex, as I cannot speak for everyone, but I will explain why I use Neomutt.<ul><li>Auto-image blocking: In the age where everyone is trying to get your attention, it is nice to have a client that doesn't render images by default. Instead of those annoying images, I get a plain view of the email, and concentrate on the content of the email.<li>Lightweight: Gmail is a resource hog. It takes seconds to load, and a pain to use when you have a slow internet connection. Neomutt loads in a fraction of a second and allows you filter through your emails quickly.<li>Configurable: Neomutt is extremely configurable. You can change the color scheme, the keybindings, and even the email client's behavior. For instance, In my current configuration, I have grammar checking, auto-completion for words, and auto-completion for email addresses. Everything is done through the keyboard.</ul><p>Now, if none of these reasons appeal to you, then Neomutt is not for you. Click the back button. But, if you are still here, then let's get started!<h2 id=installation>Installation</h2><p>For this blog, I'll be detailing the installation process for Arch Linux, Gentoo, Ubuntu, and macOS. Since I know these distributions extremely well, I can provide more detailed instructions. If you are using Windows, I recommend using WSL2, and you can follow along with the Ubuntu instructions.<h3 id=macos>macOS</h3><p>I'll be using Homebrew to install Neomutt:<p>Note: <code>$</code> is the prompt for a user without root access. You don't need to type it.<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> /bin/bash</span><span style=color:#f29718> -c </span><span style=color:#c2d94c>"$</span><span>(</span><span style=color:#ffb454>curl</span><span style=color:#f29718> -fsSL</span><span style=color:#c2d94c> https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh</span><span>)</span><span style=color:#c2d94c>"
</span><span style=color:#ffb454>$ </span><span style=font-style:italic;color:#5c6773># wait for the installation to finish and put homebrew in your path
</span><span style=color:#ffb454>$ </span><span style=font-style:italic;color:#5c6773># ...
</span><span style=color:#ffb454>$</span><span> brew install neomutt
</span><span style=color:#ffb454>$ </span><span style=font-style:italic;color:#5c6773># additionally, I would recommend installing:
</span><span style=color:#ffb454>$</span><span> brew install gnupg
</span><span style=color:#ffb454>$ </span><span style=font-style:italic;color:#5c6773># I'll explain why later
</span></code></pre><h3 id=arch-linux>Arch Linux</h3><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo pacman</span><span style=color:#f29718> -Syu</span><span> neomutt
</span><span style=color:#ffb454>$</span><span> sudo pacman</span><span style=color:#f29718> -Syu</span><span> gnupg
</span><span style=color:#ffb454>$ </span><span style=font-style:italic;color:#5c6773># or
</span><span style=color:#ffb454>$</span><span> sudo paru</span><span style=color:#f29718> -Syu</span><span> neomutt
</span><span style=color:#ffb454>$</span><span> sudo paru</span><span style=color:#f29718> -Syu</span><span> gnupg
</span></code></pre><h3 id=gentoo>Gentoo</h3><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo emerge</span><span style=color:#f29718> --ask</span><span> mail-client/neomutt
</span><span style=color:#ffb454>$</span><span> sudo emerge</span><span style=color:#f29718> --ask</span><span> app-crypt/gnupg
</span></code></pre><h3 id=ubuntu-and-wsl2-using-ubuntu>Ubuntu and WSL2 using Ubuntu</h3><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo apt install neomutt
</span><span style=color:#ffb454>$</span><span> sudo apt install gnupg
</span></code></pre><h2 id=running-neomutt-for-the-first-time>Running Neomutt for the first time</h2><p>The first time you run Neomutt, you will be greeted with a screen that looks like this that prompts you for your email address and password:<p><img alt=fresh src=https://seniormars.github.io/posts/neomutt/after_install.png><p>This is the default configuration that Neomutt comes with, but not very useful. We need to customize it first. To demonstrate how to configure Neomutt, I'll have two code blocks for each section. The first code block will be the configuration that I use, and the second code block is the one you should modify to fit your needs.<h2 id=initial-mutt-configuration>Initial Mutt Configuration</h2><p>We are going to take configuration step by step. I will explain what each section does, and why. The first we need to do is make a <code>muttrc</code> file. This file is where we will store all of our configuration. By default, Neomutt will look for a file called <code>muttrc</code> in the following location: <code>XDG_CONFIG_HOME/mutt/muttrc</code>.<p>Note:</p><center> XDG_CONFIG_HOME is an environment variable that points to the location of your configuration files. <p>Read more about it <a href=https://wiki.archlinux.org/title/XDG_Base_Directory>here</a>.</p> </center><p>For example, on my machine, the location of my <code>muttrc</code> file is <code>~/.config/mutt/muttrc</code>.<p>If this file does not exist, then you can create it by running the following command:<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> mkdir</span><span style=color:#f29718> -p </span><span style=font-style:italic;color:#39bae6>~</span><span>/.config/mutt
</span><span style=color:#ffb454>$</span><span> touch </span><span style=font-style:italic;color:#39bae6>~</span><span>/.config/mutt/muttrc
</span></code></pre><p>Let's put a hold on this to introduce the next section:<h3 id=google-gmail-and-app-specific-passwords>Google, Gmail, and App-specific passwords</h3><p>As I said before, this blog is intended for students that are forced to use Google's email platform. Which means I'll be detailing how to configure Neomutt to work with Gmail. Thus, before we move any further, it is important to get an "app-specific password" from Google.<p>Note:</p><center> An app-specific password is a password for applications that do not support 2-factor authentication or are considered "unsecure". Google wants you to use Gmail >:( </center><p>To get an app-specific password, follow these steps:<ul><li>Go to <a href=https://security.google.com/settings/security/apppasswords>Google's app-specific password page</a><li>Sign in with your Google account<li>Select “Mail” as the app or other and select “Other (custom name)” as the device. I use “Mutt” as the name.<li>Click “Generate” and copy the password that is generated. You will need this password later. Store it!<li>Profit??!!!</ul><p>Here is a screenshot of the result: <img alt="Google app password" src=https://seniormars.github.io/posts/neomutt/gpass.png><h3 id=accessing-gmail-with-neomutt>Accessing Gmail with Neomutt</h3><p>Now that we have an app-specific password, we can configure Neomutt to access Gmail. To accomplish this, let's open up our <code>muttrc</code> (i.e., <code>$EDITOR XDG_CONFIG_HOME/mutt/muttrc</code>) file with our favorite editor. I'll be using <code>nvim</code> for this blog, but you can use any editor you want. Now, let's add the following configuration to our <code>muttrc</code> file:<p>Mine:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># User
</span><span style=color:#f29718>set </span><span>from </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"cjh16@rice.edu"
</span><span style=color:#f29718>set </span><span>realname </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"Charlie Cruz"
</span><span>
</span><span style=font-style:italic;color:#5c6773># Gmail
</span><span style=color:#f29718>set </span><span>imap_user </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"cjh16@rice.edu"
</span><span style=color:#f29718>set </span><span>smtp_url </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"smtps://cjh16@rice.edu@smtp.gmail.com:465/"
</span><span style=color:#f29718>set </span><span>smtp_authenticators </span><span style=color:#f29668>= </span><span style=color:#c2d94c>'gssapi:login'
</span><span style=color:#f29718>set </span><span>imap_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"my_app_specific_password"
</span><span style=color:#f29718>set </span><span>smtp_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"my_app_specific_password"
</span><span>
</span><span style=font-style:italic;color:#5c6773># Ensure TLS is enforced
</span><span style=color:#f29718>set </span><span>ssl_starttls </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span style=color:#f29718>set </span><span>ssl_force_tls </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span></code></pre><p>Yours:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># User
</span><span style=color:#f29718>set </span><span>from </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"your_email_address"
</span><span style=color:#f29718>set </span><span>realname </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"Your Name"
</span><span>
</span><span style=font-style:italic;color:#5c6773># Gmail
</span><span style=color:#f29718>set </span><span>imap_user </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"your_email_address"
</span><span style=color:#f29718>set </span><span>smtp_url </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"smtps://YOUR_EMAIL@smtp.gmail.com:465/"
</span><span style=color:#f29718>set </span><span>smtp_authenticators </span><span style=color:#f29668>= </span><span style=color:#c2d94c>'gssapi:login'
</span><span style=color:#f29718>set </span><span>imap_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"your_app_specific_password"
</span><span style=color:#f29718>set </span><span>smtp_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"your_app_specific_password"
</span><span>
</span><span style=font-style:italic;color:#5c6773># Ensure TLS is enforced
</span><span style=color:#f29718>set </span><span>ssl_starttls </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span style=color:#f29718>set </span><span>ssl_force_tls </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span></code></pre><p>Note:</p><center> Plain text for passwords is a bad idea. See the encryption section of this blog. </center><p>Let's break down this section: First, it's pretty self-explanatory for the first few lines, but for <code>set smtp*</code>, we need to explain.<p><code>set smtp_url</code> is the URL that Neomutt will use to send emails. The format is as follows: <code>smtps://email@server:port</code>. For Gmail, the server is <code>smtp.gmail.com</code> and the port is <code>465</code>. This is from the <a href="https://support.google.com/mail/answer/7126229?hl=en">Gmail SMTP server documentation</a>.<p><code>set smtp_authenticators</code> is the authentication method that Neomutt will use to send emails. For Gmail, we will use <code>gssapi:login</code> as the authentication method.<p><code>set imap_pass</code> and <code>set smtp_pass</code> are the passwords that Neomutt will use to access your email. Note this is plaintext, we will fix this later.<p><code>set ssl_starttls</code> and <code>set ssl_force_tls</code> are used to ensure that Neomutt uses TLS when connecting to the server. This is important because Gmail will not allow you to connect to the server without these properties.<p>After you have added this configuration to your <code>muttrc</code> file, save it, and in theory, you can now access your email! But, there are a few more things we need to do to make this more useful.<h2 id=mailboxes>Mailboxes</h2><p>The next step is to specify which mailboxes you want to access. To achieve this, we add:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># My mailboxes
</span><span style=color:#f29718>set </span><span>folder </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"imaps://imap.gmail.com:993/[Gmail]"
</span><span style=color:#f29718>set </span><span>spoolfile </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"+All Mail"
</span><span style=color:#f29718>set </span><span>postponed </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"+Drafts"
</span><span style=color:#f29718>set </span><span>record </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"+Sent Mail"
</span><span style=color:#f29718>set </span><span>trash </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"+Trash"
</span><span>
</span><span style=color:#f29718>mailboxes </span><span style=color:#f29668>=</span><span>Important </span><span style=color:#f29668>=</span><span>Starred </span><span style=color:#f29668>=</span><span>Drafts </span><span style=color:#f29668>=</span><span style=color:#c2d94c>"Sent Mail" </span><span style=color:#f29668>=</span><span>Spam </span><span style=color:#f29668>=</span><span>Trash
</span><span>
</span><span style=font-style:italic;color:#5c6773># Where to put the stuff
</span><span style=color:#f29718>set </span><span>header_cache </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"$XDG_CACHE_HOME/mutt/headers"
</span><span style=color:#f29718>set </span><span>message_cachedir </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"$XDG_CACHE_HOME/mutt/bodies"
</span><span style=color:#f29718>set </span><span>certificate_file </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"$XDG_CACHE_HOME/mutt/certificates"
</span><span style=color:#f29718>unset </span><span>record
</span></code></pre><p>Let's break this down:<ul><li><code>set folder</code> is the folder that Neomutt will use to access your emails. 993 is just the port for imap.<li><code>set spoolfile</code> is your home inbox. This is the inbox that you see when you log into Gmail. You can change this to whatever you want. i.e., <code>set spoolfile = "+Important"</code>. I like to see all my emails, so I use <code>+All Mail</code>.<li><code>set record</code>, <code>set postponed</code>, and <code>set trash</code> are the folders that Neomutt will use to store emails that you have sent, drafts, and trash respectively in Gmail.<li><code>mailboxes</code> is a list of mailboxes that you want to access. You can add as many as you want, but I keep it simple with just the ones I use.<li><code>set header_cache</code> and <code>set message_cachedir</code> are the locations that Neomutt will use to cache your emails. This is important because it will make your email client much faster. <code>set certificate_file</code> is similar.<li><code>unset record</code> is used to disable the recording of sent emails. This is because Gmail already records sent emails, so we don't need to do it twice.</ul><p>At this point, you should be able to access your email! Now, let's make this even more useful.<h2 id=settings-i-highly-recommend>Settings I highly recommend</h2><p>Alright, so now that we have a basic configuration, but what about modifying how we reply to emails, or how we interact with our email client? Let's add the following to our <code>muttrc</code> file:<p>I added comments to explain what each line does.<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># settings
</span><span style=color:#f29718>set </span><span>pager_index_lines </span><span style=color:#f29668>= </span><span style=color:#f29718>10
</span><span style=color:#f29718>set </span><span>pager_context </span><span style=color:#f29668>= </span><span style=color:#f29718>3 </span><span style=font-style:italic;color:#5c6773># show 3 lines of context
</span><span style=color:#f29718>set </span><span>pager_stop </span><span style=font-style:italic;color:#5c6773># stop at end of message
</span><span style=color:#f29718>set </span><span>menu_scroll </span><span style=font-style:italic;color:#5c6773># scroll menu
</span><span style=color:#f29718>set </span><span>tilde </span><span style=font-style:italic;color:#5c6773># use ~ to pad mutt
</span><span style=color:#f29718>set </span><span>move</span><span style=color:#f29668>=</span><span style=color:#f29718>no </span><span style=font-style:italic;color:#5c6773># don't move messages when marking as read
</span><span style=color:#f29718>set </span><span>mail_check </span><span style=color:#f29668>= </span><span style=color:#f29718>30 </span><span style=font-style:italic;color:#5c6773># check for new mail every 30 seconds
</span><span style=color:#f29718>set </span><span>imap_keepalive </span><span style=color:#f29668>= </span><span style=color:#f29718>900 </span><span style=font-style:italic;color:#5c6773># 15 minutes
</span><span style=color:#f29718>set </span><span>sleep_time </span><span style=color:#f29668>= </span><span style=color:#f29718>0 </span><span style=font-style:italic;color:#5c6773># don't sleep when idle
</span><span style=color:#f29718>set </span><span>wait_key </span><span style=color:#f29668>= </span><span style=color:#f29718>no </span><span style=font-style:italic;color:#5c6773># mutt won't ask "press key to continue"
</span><span style=color:#f29718>set </span><span>envelope_from </span><span style=font-style:italic;color:#5c6773># which from?
</span><span style=color:#f29718>set </span><span>edit_headers </span><span style=font-style:italic;color:#5c6773># show headers when composing
</span><span style=color:#f29718>set </span><span>fast_reply </span><span style=font-style:italic;color:#5c6773># skip to compose when replying
</span><span style=color:#f29718>set </span><span>askcc </span><span style=font-style:italic;color:#5c6773># ask for CC:
</span><span style=color:#f29718>set </span><span>fcc_attach </span><span style=font-style:italic;color:#5c6773># save attachments with the body
</span><span style=color:#f29718>set </span><span>forward_format </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"Fwd: %s" </span><span style=font-style:italic;color:#5c6773># format of subject when forwarding
</span><span style=color:#f29718>set </span><span>forward_decode </span><span style=font-style:italic;color:#5c6773># decode when forwarding
</span><span style=color:#f29718>set </span><span>forward_quote </span><span style=font-style:italic;color:#5c6773># include message in forwards
</span><span style=color:#f29718>set </span><span>mime_forward </span><span style=font-style:italic;color:#5c6773># forward attachments as part of body
</span><span style=color:#f29718>set </span><span>attribution </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"On %d, %n wrote:" </span><span style=font-style:italic;color:#5c6773># format of quoting header
</span><span style=color:#f29718>set </span><span>reply_to </span><span style=font-style:italic;color:#5c6773># reply to Reply to: field
</span><span style=color:#f29718>set </span><span>reverse_name </span><span style=font-style:italic;color:#5c6773># reply as whomever it was to
</span><span style=color:#f29718>set </span><span style=color:#ff7733>include </span><span style=font-style:italic;color:#5c6773># include message in replies
</span><span style=color:#f29718>set </span><span>text_flowed</span><span style=color:#f29668>=</span><span style=color:#f29718>yes </span><span style=font-style:italic;color:#5c6773># correct indentation for plain text
</span><span style=color:#f29718>unset </span><span>sig_dashes </span><span style=font-style:italic;color:#5c6773># no dashes before sig
</span><span style=color:#f29718>unset </span><span>markers
</span><span>
</span><span style=font-style:italic;color:#5c6773># Sort by newest conversation first.
</span><span style=color:#f29718>set </span><span>charset </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"utf-8"
</span><span style=color:#f29718>set </span><span>uncollapse_jump
</span><span style=color:#f29718>set </span><span>sort_re
</span><span style=color:#f29718>set </span><span>sort </span><span style=color:#f29668>=</span><span> reverse</span><span style=color:#f29668>-</span><span>threads
</span><span style=color:#f29718>set </span><span>sort_aux </span><span style=color:#f29668>=</span><span> last</span><span style=color:#f29668>-</span><span>date</span><span style=color:#f29668>-</span><span>received
</span><span style=font-style:italic;color:#5c6773># How we reply and quote emails.
</span><span style=color:#f29718>set </span><span>reply_regexp </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
</span><span style=color:#f29718>set </span><span>quote_regexp </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
</span><span style=color:#f29718>set </span><span>send_charset </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"utf-8:iso-8859-1:us-ascii" </span><span style=font-style:italic;color:#5c6773># send in utf-8
</span></code></pre><p>I highly recommend these settings, but you may want to change <code>askcc, edit_headers, fast_reply, envelope_from</code>.<h2 id=sidebar>Sidebar</h2><p>The sidebar is a very useful feature that allows you to see all your mailboxes in a sidebar. Here is a screenshot of what it looks like:<p><img alt=Sidebar src=https://seniormars.github.io/posts/neomutt/sidebar.png><p>Here is how to add it to your <code>muttrc</code> file:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773>#sidebar
</span><span style=color:#f29718>set </span><span>sidebar_visible </span><span style=font-style:italic;color:#5c6773># comment to disable sidebar by default
</span><span style=color:#f29718>set </span><span>sidebar_short_path
</span><span style=color:#f29718>set </span><span>sidebar_folder_indent
</span><span style=color:#f29718>set </span><span>sidebar_format </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"%B %* [%?N?%N / ?%S]"
</span><span style=color:#f29718>set </span><span>mail_check_stats
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span style=font-style:italic;color:#f29668>CJ</span><span> sidebar</span><span style=color:#f29668>-</span><span>prev
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span style=font-style:italic;color:#f29668>CK</span><span> sidebar</span><span style=color:#f29668>-</span><span>next
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span style=font-style:italic;color:#f29668>CE</span><span> sidebar</span><span style=color:#f29668>-</span><span>open
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=font-style:italic;color:#f29668>B</span><span> sidebar</span><span style=color:#f29668>-</span><span>toggle</span><span style=color:#f29668>-</span><span>visible
</span></code></pre><p>Now, you should be able to see the sidebar when you open your email client and press <code>&LTshift-b></code> to toggle it!<h2 id=signature>Signature</h2><p>The signature is the text that you add to the bottom of your emails. To add it to Neomutt, you need to:<ol><li>Create a file (call it <code>signature</code> or whatever you prefer)<li>Add your signature to the file. For example, here is mine:</ol><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> cat signature
</span><span>
</span><span style=color:#ffb454>---
</span><span style=color:#ffb454>Charlie</span><span> Cruz</span><span style=color:#f29668> --</span><span> changing my legal name!
</span><span style=color:#ffb454>Math </span><span style=color:#f29668>& </span><span style=color:#ffb454>Linguistics</span><span> @ Rice University </span><span style=color:#c2d94c>'26
</span></code></pre><ol start=3><li>link the file to your <code>muttrc</code> file:</ol><pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>set </span><span>signature </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"$XDG_CONFIG_HOME/mutt/signature"
</span></code></pre><p>Now, when you send an email, your signature will be added to the bottom of the email.<h2 id=editor>Editor</h2><p>The editor is the program that you use to compose emails. By default, Neomutt uses <code>vi</code> as the editor, but you can change this to whatever you want. For instance, I use <code>nvim</code> as my editor, so I add the following to my <code>muttrc</code> file:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>set </span><span>editor </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"nvim"
</span></code></pre><p>Note:</p><center> In (Neo)Vim with patch 6e649224926b and partial 113cb513f76d now include mail.vim, which is a filetype plugin for mail. This plugin provides syntax highlighting, indentation, and other features for mail files. </center><h3 id=n-vim-and-mail>(N)vim and Mail</h3><p>If you use <code>nvim</code> as your editor, you may want to add the following to your <code>nvim/after/ftplugin/mail.{lua,vim}</code> file:<p>Lua:<pre class=language-lua data-lang=lua style=background:#0f1419;color:#bfbab0><code class=language-lua data-lang=lua><span>vim</span><span style=color:#f29668>.</span><span>opt_local</span><span style=color:#f29668>.</span><span>spell </span><span style=color:#f29668>= </span><span style=color:#f29718>true
</span><span>vim</span><span style=color:#f29668>.</span><span>opt_local</span><span style=color:#f29668>.</span><span>spelllang </span><span style=color:#f29668>= </span><span style=color:#c2d94c>'en_us'
</span><span>vim</span><span style=color:#f29668>.</span><span>opt_local</span><span style=color:#f29668>.</span><span>fo</span><span style=color:#f29668>:</span><span style=color:#ffb454>append</span><span>(</span><span style=color:#c2d94c>'aw'</span><span>)
</span><span style=color:#ff7733>local </span><span>map </span><span style=color:#f29668>= </span><span>vim</span><span style=color:#f29668>.</span><span>api</span><span style=color:#f29668>.</span><span>nvim_buf_set_keymap
</span><span style=color:#ff7733>local </span><span>options </span><span style=color:#f29668>= </span><span>{ </span><span style=color:#c2d94c>noremap </span><span style=color:#bfbab0cc>= </span><span style=color:#f29718>true</span><span style=color:#bfbab0cc>, </span><span style=color:#c2d94c>silent </span><span style=color:#bfbab0cc>= </span><span style=color:#f29718>true</span><span>}
</span><span style=color:#ffb454>map</span><span>(</span><span style=color:#f29718>0</span><span style=color:#bfbab0cc>, </span><span style=color:#c2d94c>'n'</span><span style=color:#bfbab0cc>, </span><span style=color:#c2d94c>'&LTleader>x'</span><span style=color:#bfbab0cc>, </span><span style=color:#c2d94c>'ZZ'</span><span style=color:#bfbab0cc>, </span><span>options)
</span></code></pre><p>Vim:<pre class=language-vim data-lang=vim style=background:#0f1419;color:#bfbab0><code class=language-vim data-lang=vim><span style=color:#f07178>setlocal</span><span> spell
</span><span style=color:#f07178>setlocal</span><span> spelllang=en_us
</span><span style=color:#f07178>setlocal</span><span> fo+=aw
</span><span style=color:#f07178>nnoremap </span><span style=font-style:italic;color:#39bae6>&LTleader></span><span>x ZZ
</span></code></pre><p>These settings will enable spell checking, better paragraph wrapping, and <code>&LTleader>x</code> will save and quit.<h3 id=keybindings>Keybindings</h3><p>I highly recommend adding the following keybindings to your <code>muttrc</code> file for more vim-like keybindings:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#ff7733>macro index </span><span style=font-style:italic;color:#f29668>A </span><span style=color:#f29668>\
</span><span> </span><span style=color:#c2d94c>"&LTtag-pattern>~N&LTenter>&LTtag-prefix>&LTclear-flag>N&LTuntag-pattern>.&LTenter>" </span><span style=color:#f29668>\
</span><span> </span><span style=color:#c2d94c>"mark all new as read"
</span><span>
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span> j next</span><span style=color:#f29668>-</span><span>entry
</span><span style=color:#f29718>bind </span><span style=color:#ff7733>index</span><span> k previous</span><span style=color:#f29668>-</span><span>entry
</span><span style=color:#f29718>bind </span><span>pager j next</span><span style=color:#f29668>-</span><span>line
</span><span style=color:#f29718>bind </span><span>pager k previous</span><span style=color:#f29668>-</span><span>line
</span><span>
</span><span style=color:#f29718>bind </span><span>attach</span><span style=color:#f29668>,</span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span style=font-style:italic;color:#f29668>CD</span><span> next</span><span style=color:#f29668>-</span><span>page
</span><span style=color:#f29718>bind </span><span>attach</span><span style=color:#f29668>,</span><span style=color:#ff7733>index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span style=font-style:italic;color:#f29668>CU</span><span> previous</span><span style=color:#f29668>-</span><span>page
</span><span style=color:#f29718>bind </span><span>pager g top
</span><span style=color:#f29718>bind </span><span>pager </span><span style=font-style:italic;color:#f29668>G</span><span> bottom
</span><span style=color:#f29718>bind </span><span>attach</span><span style=color:#f29668>,</span><span style=color:#ff7733>index</span><span> g first</span><span style=color:#f29668>-</span><span>entry
</span><span style=color:#f29718>bind </span><span>attach</span><span style=color:#f29668>,</span><span style=color:#ff7733>index </span><span style=font-style:italic;color:#f29668>G</span><span> last</span><span style=color:#f29668>-</span><span>entry
</span></code></pre><p>The first marco isn't very vim-like, but it is very useful. It allows you to mark all new emails as read by pressing <code>A</code> in the index.<p>The next set of keybindings are for scrolling. I use <code>j</code> and <code>k</code> to scroll up and down, and <code>g</code> and <code>G</code> to go to the top and bottom of the page.<h2 id=mailcap>Mailcap</h2><p>The mailcap file is used to determine how to open attachments. For instance, if you have a <code>.pdf</code> file, you would want to open it with your prefer PDF viewer. This is most useful for rendering HTML in emails.<ol><li>Create a file called <code>mailcap</code> in your <code>$XDG_CONFIG_HOME/mutt</code> directory.<li>Add the following to the file:</ol><pre style=background:#0f1419;color:#bfbab0><code><span>text/html; firefox %s; test=test -n "$display"; needsterminal;
</span><span>text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump -width=1024 %s; nametemplate=%s.html; copiousoutput;
</span><span>text/plain; cat %s; copiousoutput
</span><span>application/pdf; firefox %s; test=test -n "$display"; needsterminal;
</span></code></pre><p>Of course, you can change the browser, and pdf viewer to whatever you want. On Mac, you might want <code>open -a firefox %s</code> or <code>open -a Preview %s</code>.<p>Note:</p><center> Firefox now supports editing PDFs! </center><ol start=3><li>Now install <code>lynx</code></ol><p>macOS<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> brew install lynx
</span></code></pre><p>Arch Linux<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo pacman</span><span style=color:#f29718> -Syu</span><span> lynx </span><span style=font-style:italic;color:#5c6773># or paru -Syu lynx
</span></code></pre><p>Gentoo<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo emerge</span><span style=color:#f29718> -av</span><span> www-client/lynx
</span></code></pre><p>Ubuntu<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> sudo apt install lynx
</span></code></pre><ol start=4><li>Link the file to your <code>muttrc</code> file and add the following to your <code>muttrc</code> file:</ol><pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># link to mailcap file
</span><span style=color:#f29718>set </span><span>mailcap_path </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"$XDG_CONFIG_HOME/mutt/mailcap"
</span><span style=font-style:italic;color:#5c6773># open attachments with mailcap with &LTreturn>
</span><span style=color:#f29718>bind </span><span>attach </span><span style=color:#f29668><</span><span>return</span><span style=color:#f29668>></span><span> view</span><span style=color:#f29668>-</span><span>mailcap
</span><span style=font-style:italic;color:#5c6773># save attachments to a folder
</span><span style=color:#ff7733>macro</span><span> attach s </span><span style=color:#c2d94c>'&LTsave-entry> &LTbol>~/Documents/attachments/&LTeol>' 'save attachment'
</span><span style=color:#f29718>auto_view </span><span style=font-style:italic;color:#39bae6>text/html </span><span style=font-style:italic;color:#5c6773># automatically show html (mailcap uses lynx)
</span></code></pre><p>You can see more mailcap examples in my dotfiles <a href=https://github.com/SeniorMars/dotfiles/blob/master/.config/mutt/mailcap>here</a>.<p>Now you should be able to open attachments with your prefered program and automatically render HTML in emails! NO PICTURES THOUGH :)<h2 id=colors>Colors</h2><p>You can change the colors of Neomutt by adding the following to your <code>muttrc</code> file:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>color </span><span>status green default
</span><span style=font-style:italic;color:#5c6773># in general, the order is:
</span><span style=font-style:italic;color:#5c6773># color &LTelement> &LTcolor> &LTattr> optional&LTregex>
</span></code></pre><p>My theme can be found <a href=https://github.com/SeniorMars/dotfiles/blob/master/.config/mutt/colors.muttrc>here</a>.<h2 id=external-programs>External programs</h2><p>While, Neomutt is a great email client, it is not perfect. For instance, it doesn't have a built-in query support, urls are not clickable, and it doesn't encrypt emails. To resolve these issues, we can use external programs.<h3 id=urlscan>Urlscan</h3><p>Let's take a look at the first issue: urls are not clickable. To fix this, we can use <code>urlscan</code> to make urls clickable.<p>The GitHub repo for <code>urlscan</code> is <a href=https://github.com/firecat53/urlscan>here</a>, and you can install it via pip:<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> pip install</span><span style=color:#f29718> --user</span><span> urlscan
</span></code></pre><p>Now, we need to add the following to our <code>muttrc</code> file:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#ff7733>macro index</span><span style=color:#f29668>,</span><span>pager </span><span style=color:#f29668>\</span><span>cb </span><span style=color:#c2d94c>"&LTpipe-message> urlscan&LTEnter>" "call urlscan to extract URLs out of a message"
</span><span style=color:#ff7733>macro</span><span> attach</span><span style=color:#f29668>,</span><span>compose </span><span style=color:#f29668>\</span><span>cb </span><span style=color:#c2d94c>"&LTpipe-entry> urlscan&LTEnter>" "call urlscan to extract URLs out of a message"
</span></code></pre><p>Now, when you press <code>&LTCtrl+b></code> in the index or pager, <code>urlscan</code> will be called and the urls will be extracted. You can then press <code>&LTEnter></code> to open the url in your browser.<p>See image below:<p><img alt=Urls src=https://seniormars.github.io/posts/neomutt/urls.png><h3 id=query>Query</h3><p>The next issue is that Neomutt doesn't have a built-in query support. To fix this, we can use <code>goobook</code> to search our contacts or <code>lbdbq</code> to use apple's address book.<p>For goobook, I recommend looking at archlinux's <a href=https://wiki.archlinux.org/title/Mutt#Goobook>wiki</a> for more information. It basically comes down to getting a token from Google.<p>Since, I currently use macOS, I will show you how to use <code>lbdbq</code> to search my contacts.<ol><li>Install <code>lbdbq</code>:</ol><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> brew install lbdbq
</span></code></pre><ol start=2><li>Modify <code>lbdbq</code>'s config file (either <code>$HOME/.lbdbrc</code> or <code>/opt/homebrew/Cellar/lbdb/0.51.1/etc/lbdb.rc</code>) to include the following:</ol><pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#f29668>METHODS</span><span style=color:#f29668>=</span><span style=color:#c2d94c>"m_inmail m_osx_addressbook m_muttalias"
</span></code></pre><p>You are done!<ol start=3><li>Add the following to your <code>muttrc</code> file:</ol><pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>set </span><span>query_command</span><span style=color:#f29668>=</span><span style=color:#c2d94c>"/opt/homebrew/bin/lbdbq '%s'"
</span><span style=color:#f29718>bind </span><span>editor </span><span style=color:#f29668><</span><span>Tab</span><span style=color:#f29668>></span><span> complete</span><span style=color:#f29668>-</span><span>query
</span></code></pre><p>Now, when you press <code>&LTTab></code> in the editor when prompted for an email, you will be able to search your MacBook contacts!<p>Note:</p><center> You can add your Google contacts to your MacBook contacts by linking your Google account to your MacBook contacts. Which is not great, but I still did it. </center><h3 id=encrypt>Encrypt</h3><p>I use <code>gpg</code> to encrypt my emails. This is very useful for GitHub, and other services that require security. This is especially useful on mailing lists where you need to verify information. I find that everyone in the Arch Linux Mailing list uses it!<ol><li>We already installed <code>gpg</code> in the beginning, so we are good to go!<li>Create a key and follow the instructions that are prompted:</ol><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> gpg</span><span style=color:#f29718> --full-generate-key
</span></code></pre><ol start=3><li>Copy your public key:</ol><pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> gpg</span><span style=color:#f29718> --list-secret-keys --keyid-format</span><span style=color:#f29668>=</span><span>long
</span></code></pre><p>For instance, my public key is: <code>7C668A6D13D5729989FB126B183357B41320BB2B</code>. You can see the full version here: <a href=https://github.com/SeniorMars.gpg>https://github.com/SeniorMars.gpg</a><ol start=4><li>Add the following to your <code>muttrc</code> file:</ol><pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=font-style:italic;color:#5c6773># Use GPGME
</span><span style=font-style:italic;color:#5c6773># Use my key for signing and encrypting
</span><span style=color:#f29718>set </span><span>pgp_default_key </span><span style=color:#f29668>=</span><span> 7C668A6D13D5729989FB126B183357B41320BB2B
</span><span>
</span><span style=font-style:italic;color:#5c6773># Use GPGME
</span><span style=color:#f29718>set </span><span>crypt_use_gpgme </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Automatically sign all out-going email
</span><span style=color:#f29718>set </span><span>crypt_autosign </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Sign replies to signed emails
</span><span style=color:#f29718>set </span><span>crypt_replysign </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Encrypt replies to encrypted emails
</span><span style=color:#f29718>set </span><span>crypt_replyencrypt </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Encrypt and sign replies to encrypted and signed email
</span><span style=color:#f29718>set </span><span>crypt_replysignencrypted </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Attempt to verify signatures automatically
</span><span style=color:#f29718>set </span><span>crypt_verify_sig </span><span style=color:#f29668>= </span><span style=color:#f29718>yes
</span><span>
</span><span style=font-style:italic;color:#5c6773># Attempt to encrypt automatically, if possible
</span><span style=font-style:italic;color:#5c6773># I would recommend setting this to no as university often have spam filters
</span><span style=font-style:italic;color:#5c6773># And this will cause your emails to be marked as spam
</span><span style=font-style:italic;color:#5c6773># as they can't decrypt your emails LMAO
</span><span style=color:#f29718>set </span><span>crypt_opportunistic_encrypt </span><span style=color:#f29668>= </span><span style=color:#f29718>no
</span><span>
</span><span style=font-style:italic;color:#5c6773># So you can view encrypted emails automatically
</span><span style=color:#f29718>auto_view </span><span style=font-style:italic;color:#39bae6>application/pgp-encrypted
</span></code></pre><ol start=5><li>Plaintext is a bad idea, which is why we are going to use GPG to encrypt our passwords.</ol><p>In your <code>muttrc</code> delete the following lines:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>set </span><span>imap_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"my_app_specific_password"
</span><span style=color:#f29718>set </span><span>smtp_pass </span><span style=color:#f29668>= </span><span style=color:#c2d94c>"my_app_specific_password"
</span></code></pre><p>Now go to your terminal and create a file called <code>passwords</code> in your <code>muttrc</code> directory and add the lines you just deleted. Now, encrypt the file:<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> gpg</span><span style=color:#f29718> --encrypt --sign -r</span><span> YOUR_GPG_KEY passwords
</span></code></pre><p>You should end up with a file called <code>passwords.gpg</code> in your <code>muttrc</code> directory.<p>Now, add the following to your <code>muttrc</code> file:<pre class=language-conf data-lang=conf style=background:#0f1419;color:#bfbab0><code class=language-conf data-lang=conf><span style=color:#f29718>source </span><span style=color:#c2d94c>"gpg -dq $XDG_CONFIG_HOME/passwords.gpg |"
</span></code></pre><p>Remove the plaintext <code>passwords</code> file.<pre class=language-bash data-lang=bash style=background:#0f1419;color:#bfbab0><code class=language-bash data-lang=bash><span style=color:#ffb454>$</span><span> shred</span><span style=color:#f29718> -u</span><span> passwords
</span></code></pre><p>Now, you have encrypted your passwords!<p>Image below (notice the <code>Good signature</code> and <code> The following data is signed</code>): <img alt=GPG src=https://seniormars.github.io/posts/neomutt/gpg.png><p>And that's it! You should now have a fully functional email client!<h1 id=conclusion>Conclusion</h1><p>I hope you enjoyed this tutorial! If you have any questions, don't ask /s.<p>I am going to upload a talk I gave on setting up Neovim for non-programmers soon. This talks about grammar checking, spell keybinds, and more. So stay tuned!<p>Thanks for reading and have a nice day!<p>SeniorMars</section></article></main></div>