Neomutt on OpenBSD

I setup neomutt on my NetBSD Nuc; however, I did not write down what I did. We are moving and packing all the non-essentials. Dang! I packed my Nuc and my OpenBSD desktop. I am using my Lenovo X1 Carbon running OpenBSD. I want to use neomutt on my laptop. With the help of chatGPT, this is what I did.

My layout:

~/.muttrc
~/.mailcap

~/.mutt/
├── colors
├── mailboxes
├── signature
└── gmail-password.gpg

1. ~/.muttrc

# Mutt Configuration
# ============================================================

# ------------------------------------------------------------
# Identity
# ------------------------------------------------------------

set from = "xxxxxxxxxx@gmail.com"
set realname = "Ron Georgia"


# ------------------------------------------------------------
# Gmail IMAP
# ------------------------------------------------------------

set imap_user = "xxxxxxxxxx@gmail.com"

set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"

set record = "+[Gmail]/Sent Mail"
set postponed = "+[Gmail]/Drafts"
set trash = "+[Gmail]/Trash"


# ------------------------------------------------------------
# Gmail SMTP
# ------------------------------------------------------------

set smtp_url = "smtps://xxxxxxxxxx@gmail.com@smtp.gmail.com:465/"

# Automatic authentication selection gave:
#     No authenticators available
#
# Explicit LOGIN works with this NetBSD/NeoMutt installation.
set smtp_authenticators = "login"


# ------------------------------------------------------------
# Credentials
# ------------------------------------------------------------

# Decrypt Gmail App Password using GPG.
source "gpg -dq ~/.mutt/gmail-password.gpg |"


# ------------------------------------------------------------
# SSL/TLS
# ------------------------------------------------------------

set ssl_force_tls = yes


# ------------------------------------------------------------
# Message cache
# ------------------------------------------------------------

set header_cache = "~/.cache/mutt/headers"
set message_cachedir = "~/.cache/mutt/bodies"


# ------------------------------------------------------------
# General behavior
# ------------------------------------------------------------

set move = no
set delete = yes
set confirmappend = no
set sort = "reverse-date"


# ------------------------------------------------------------
# Editor
# ------------------------------------------------------------

set editor = "nvim"


# ------------------------------------------------------------
# Signature
# ------------------------------------------------------------

set signature = "~/.mutt/signature"


# ------------------------------------------------------------
# MIME / HTML / Attachments
# ------------------------------------------------------------

set mailcap_path = "~/.mailcap"

# NOTE:
# NeoMutt 20260616 on this NetBSD installation uses the
# underscore forms, NOT auto-view / alternative-order.

auto_view text/html
alternative_order text/plain text/html


# ------------------------------------------------------------
# Gmail Mailboxes / Labels
# ------------------------------------------------------------

source ~/.mutt/mailboxes


# ------------------------------------------------------------
# Sidebar
# ------------------------------------------------------------

set sidebar_visible = yes
set sidebar_width = 25

set sidebar_short_path = yes
set sidebar_folder_indent = yes
set sidebar_indent_string = "  "

set mail_check_stats
set mail_check_stats_interval = 60

# %D = descriptive mailbox name
# %N = unread messages
# %S = total messages
set sidebar_format = "%D%* %?N?%N/?%S"

# Toggle sidebar
bind index,pager B sidebar-toggle-visible

# Vim-style sidebar navigation
bind index,pager K sidebar-prev
bind index,pager J sidebar-next
bind index,pager L sidebar-open


# ------------------------------------------------------------
# Colors
# ------------------------------------------------------------

source ~/.mutt/color

2. ~/.mutt/mailboxes

This sets up my Gmail Mailboxes in a separate file. This removes clutter from the main .muttrc file, which is important to me.

# ============================================================
# Gmail Mailboxes
# ============================================================

# Gmail system folders
mailboxes -label "Inbox"    "+INBOX"
mailboxes -label "All Mail" "+[Gmail]/All Mail"
mailboxes -label "Drafts"   "+[Gmail]/Drafts"
mailboxes -label "Sent"     "+[Gmail]/Sent Mail"
mailboxes -label "Starred"  "+[Gmail]/Starred"
mailboxes -label "Trash"    "+[Gmail]/Trash"

# Optional
mailboxes -label "Important" "+[Gmail]/Important"
mailboxes -label "Spam"      "+[Gmail]/Spam"

To see the names Gmail is advertising through IMAP, inside neomutt: c

3. ~/.mutt/colors

Yes, I like color. Personally, I feel it brings a little warmth to a very sterile terminal.

# ============================================================
# NeoMutt Colors
# ============================================================

# General
color normal         white       default
color index          white       default
color status         black       cyan
color indicator      black       yellow
color error          red         default
color message        green       default


# ------------------------------------------------------------
# Headers
# ------------------------------------------------------------

color hdrdefault     cyan        default
color header         yellow      default "^Subject:"
color header         green       default "^From:"
color header         cyan        default "^To:"


# ------------------------------------------------------------
# Quoted text
# ------------------------------------------------------------

color quoted         cyan        default
color quoted1        green       default
color quoted2        yellow      default
color quoted3        magenta     default


# ------------------------------------------------------------
# Signature
# ------------------------------------------------------------

color signature      blue        default


# ------------------------------------------------------------
# URLs and email addresses
# ------------------------------------------------------------

color body cyan default "(https?|ftp)://[^ ]+"
color body green default "[-a-z_0-9.%$]+@[-a-z_0-9.]+"


# ------------------------------------------------------------
# Sidebar
# ------------------------------------------------------------

color sidebar_background default default
color sidebar_ordinary   white   default
color sidebar_new        green   default
color sidebar_flagged    yellow  default
color sidebar_indicator  black   cyan
color sidebar_highlight  black   yellow

4. ~/.mailcap

The .mailcap file handles HTML mail and image/PDF attachments.

When reading a message containing an embedded image: v

? opens the MIME/attachment list.

Select the image and use: m

Invoke the mailcap viewer.

For example:

image/jpeg → feh image/png → feh PDF → mupdf

# ============================================================
# NeoMutt Mailcap
# ============================================================

# HTML email
text/html; lynx -dump %s; copiousoutput

# Images
image/jpeg; feh %s
image/png;  feh %s
image/gif;  feh %s
image/webp; feh %s

# PDF
application/pdf; mupdf %s

5. ~/.mutt/signature

For example:

– Your Name your_email@gmail.com “clever saying”

6. Encrypted Gmail credentials

The unencrypted temporary file looks like this:

set imap_pass = “YOUR_16_CHARACTER_GOOGLE_APP_PASSWORD” set smtp_pass = “YOUR_16_CHARACTER_GOOGLE_APP_PASSWORD”

For example, initially create:

nvim ~/.mutt/gmail-password

Then encrypt it:

gpg -c ~/.mutt/gmail-password

That creates:

~/.mutt/gmail-password.gpg

Then remove the plaintext version:

rm ~/.mutt/gmail-password

Your .muttrc decrypts it at runtime with:

source “gpg -dq ~/.mutt/gmail-password.gpg | “

Now my Google App Password never needs to reside unencrypted in .muttrc.

7. Create cache directories

Neomutt uses these:

mkdir -p ~/.cache/mutt/headers mkdir -p ~/.cache/mutt/bodies

I want to protect my configuration directory as well:

chmod 700 ~/.mutt chmod 600 ~/.muttrc chmod 600 ~/.mutt/mailboxes chmod 600 ~/.mutt/colors chmod 600 ~/.mutt/signature chmod 600 ~/.mutt/gmail-password.gpg

The permissions on mailboxes, colors, and signature don’t strictly need to be 600, but there’s no harm in keeping the whole configuration private.

Conceptual Summary

Chat provided a cool ASCII conceptual diagram, which I like.

               ┌─────────────────────┐
                     ~/.muttrc                                                          Main configuration                 └─────────┬───────────┘
                                 ┌────────────────┼──────────────────┐
                                                                                    ▼
~/.mutt/colors   ~/.mutt/mailboxes   ~/.mailcap
                                              appearance       Gmail labels       MIME viewers
                                                                              ┌───────┼───────┐
                                                                                  lynx     feh     mupdf

               ~/.mutt/gmail-password.gpg
                                                                    GPG decrypts
                                       ┌──────────┴──────────┐
                                             imap_pass             smtp_pass
                                                                             imap.gmail.com        smtp.gmail.com