RSS Amplifier

naff.dev · Nov 3, 2025

Migrating from Mutt to NeoMutt

0
Sign in to vote or save

naff.dev

I’ve used Mutt as my primary email client for the past year or so. I have it nicely integrated with Emacs and it’s pleasant to use. The most frustrating thing about using it is that switching between my email accounts takes several seconds each time. The message bar at the bottom of the screen displays “Sorting mailbox…” for the majority of this time. By some rough-and-ready print-debugging, I found out that an imap_buffy_check call was happening every time I switched mailbox, and this looked to be contacting every IMAP server I had configured. I could comment this call out and make things run quicker, but I wasn’t sure if I was breaking something else by doing so. In the end, I forgot about this investigative work and just made do with the delay.

Some time later I tried out NeoMutt on a whim, and found it didn’t have the same issue. I’ve since migrated my Mutt setup over. The two projects diverged nearly a decade ago, so I had to make several changes to my configuration, which I’ll outline here in case anybody else wants to do the same thing.

Background Edit

Mutt supports setting background_edit to allow continuing to use it while you’re composing an email. NeoMutt doesn’t support this, so I just commented it out.

Random Message-IDs

Leaking the hostname of the machine I used to write an email in every Message-ID never sat quite right with me. In Mutt, I used set message_id_format = "%x%x%x%x%x%x%x%x@%x%x%x%x%x%x%x%x" to generate a fully random Message-ID every time.

NeoMutt doesn’t support this option, but I was able to adapt a similar setup by Konstantin Ryabitsev. I have a config fragment in a file called random_msgid as follows:

my_hdr Message-ID: <`hexdump -e '"%08x%08x@%08x%08x"' -n16 /dev/urandom`>

This just uses some standard shell commands to generate a random Message-ID and set it with my_hdr. The commands between the backticks will only execute once so we can’t put this in our main config file, or the Message-ID will be the same each time. Instead, we source this fragment from the main config file every time we send a message:

send-hook . "source ~/.config/mutt/random_msgid"

When I started NeoMutt, all of my mailboxes in the sidebar were missing their labels, only displaying INBOX. I had customised my sidebar_format in Mutt, using %B in the format string to display the mailbox name. In NeoMutt, this should be changed to %D to use the mailbox’s descriptive name. If you haven’t customised this variable, the NeoMutt default is fine.

Folder Hook

To manage multiple accounts on multiple mailservers with Mutt, I have account-hooks to set the IMAP credentials and folder-hooks to set the SMTP credentials and keybindings. The former set trigger whenever Mutt uses the account in the background, and the latter when I switch to viewing it. However, the folder-hooks were not triggering in NeoMutt, so I wasn’t able to archive emails or use the correct From address.

It turns out NeoMutt matches the regular expression for a folder-hook to a URL that includes the IMAP username for the mailbox. For example, Mutt would use imaps://imap.gmail.com whereas NeoMutt would use imaps://example@gmail.com@imap.gmail.com. My regular expressions included the protocol so weren’t matching in NeoMutt. Changing from folder-hook imaps://imap.gmail.com to folder-hook imap.gmail.com fixed the issue.

Browser Sort

In NeoMutt, pressing y to change mailbox didn’t show them in the same order as they were in the sidebar. To fix this, I just had to set browser_sort = unsorted.

Unlike Mutt, the mailbox starts the cursor at the top each time, rather than on the current mailbox. I haven’t found a way to make this work identically in NeoMutt yet.

IMAP Hangs

In NeoMutt I’ve had several hangs that have required me to kill it externally. When they occur, the last message printed is about a TLS socket error. I suspend and restore my machine frequently, so it’s possible an IMAP connection is ending up in an unexpected state. I enabled imap_passive (as it is by default) and these seem to have stopped occurring, though it’s hard to say conclusively that it hasn’t just reduced their frequency.

Conclusion

Aside from the loss of background_edit and the different cursor behaviour on changing mailbox, my experience with NeoMutt has been much the same as with Mutt—which is a good thing! When I get some time I’d like to continue investigating the initial Mutt hangs, even if it’s only so far as to be able to open a good issue report.

I have an eye on Meli and aerc as potential future clients. I’m not an email power user, and I think there’s value in a simpler client. I’m sure some people have an incredible Mutt configuration tuned over decades that they could never leave, but most of mine feels like it’s working around Mutt not originally being developed with multiple IMAP accounts in mind.

Read the original on naff.dev

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.