11:59 PM

Gemini Proxy


Home
Reload

gem.sdf.org

Using mutt for email

 

Mutt is a venerable, old, text-based email reader. I used to use it exclusively back in the 1990s and early 2000s. (After I replaced Pine with it as my daily driver.) 

 

The Mutt home page

 

It's very lightweight with a good TUI. And I decided I wanted to try to use it again after being a long-time Thunderbird user. 

 

Why? It's complicated. But one thing is sort of the same reason I like Vim: it's snappy and keyboard-based. GUI apps for me have an innate slowness that brought about by using the mouse to do things. Yes, there are a lot of shortcuts in Thunderbird (and I use them a lot), but there's something to be said for "keyboard first" applications. 

 

But there were several potential issues. 

 

  • Modern mail uses a lot of IMAP.
  • A lot of IMAP uses oAuth and other complex authentication schemes.
  • I have multiple email accounts and Mutt isn't super friendly with that.
  • Tons of email is now HTML.
  • A good portion of those tons are either HTML-only, or have a text portion that's not well-formed.
  • I have 500 entries in my contacts list. The old "make that an alias in the rc script" trick seems underpowered.
  • I need to have passwords to access some of the servers. And in a more trusting era, these would go in my rc files, chmod 600. But I don't want to do that.

 

I know there are other tools to do offline syncing of IMAP so they just appear as local mbox files. But I wanted to keep the number of dependencies small, so I just went for plain Mutt as much as I could. 

 

IMAP and oAuth

 

Mutt ships with a helper script called mutt_oauth2.py that works with Microsoft and Google. But you need to have an "app" defined on the remote side that handles the authentication. 

 

You can sometimes create an app and then set it up with that. But on my system (using Microsoft), I didn't have permission to do that. 

 

There's a workaround: pretend to be Thunderbird! TB has credentials that you can underhandedly use. As far as the remote side is concerned, you're Thunderbird. 

 

That's what I ended up doing. 

 

Regular IMAP with passwords

 

I already had GPG set up with a keypair (like everyone should), and it turns out that works wonders with the `pass` password manager. And you can throw that in the muttrc file like this: 

 

set imap_pass = `pass email/mutt/beej@beej.us`
set smtp_pass = `pass email/mutt/beej@beej.us`

 

That runs the `pass` program (that prompts me for my GPG password) which decrypts the password file and uses it for Mutt's needs. This way I don't have to hardcode a password in there and I can sync this config to my private GitHub repo with the rest of my config stuff. 

 

Multiple accounts

 

This is a bit of a pain. 

 

The approach I went with was: 

 

  • Make a macro that reads a specific RC file when hit.
  • That RC file resets all the variables about the servers.
  • Then it sets it up for the new servers.

 

This mostly works. 

 

One catch is that the folder browser caches the old folder path after you change, and there's no way to clear that explicitly. 

 

So the macro is actually: 

 

  • Switch the folder path to `~` (home directory)
  • Reset all the server variables to the new values.
  • Switch the folder path to `!` (inbox)

 

That seems to handle it without any weird errors. 

 

Contacts search

 

I still use Google for two things: contacts and calendar. It has a CSV export for contacts, and Mutt allows you to run an external script for searching for contacts. So I wrote one in AWK. 

 

Now I type the first few letters of a name or email and hit ^T. That brings up the completion menu. 

 

Still a manual process to export the contacts from Google, though. 

 

HTML

 

I tried w3m, lynx, pandoc, and cha for converting HTML to text. I like Lynx because of the link footnotes it adds. 

 

But I settled on w3m eventually for its better table and div handling. 

 

Sometimes that's not enough. 

 

I added a macro "H" to the attachment viewer screen that would pop HTML attachments open in a browser. This brings up an external script that the HTML is piped into. The script saves it to a file, runs `xgd-open` or `open` (Mac) on the file, then deletes it after 5 seconds (enough time for the browser to open it). Attached images don't show up, but it's good enough to work. 

 

Other attachments

 

I have a similar script for opening other attachments like images. This doesn't delete the file after 5 seconds because my image viewer detects this and removes the image from the screen. 

 

So this variant opens the file, but then waits until you hit RETURN to remove it. 

 

Conclusion

 

I like it. 

 

Somehow it has brought back the joy of email in a way I didn't expect. Sure I don't see all my accounts on the left of the screen and I have to manually switch between them, but in a way that's better. 

 

I'm sure it's not for everyone, but I'm extremely gratified I got it working. All it took was hours and hours of tuning and troubleshooting. But _now_ it's solid. :) 

 

─────────── 

 

Comments? Mail beej@beej.us.

Back to Beej's Gemlog

Back to Beej's Place

 

Document: Done in 0.61s

Open Location

Open Location:

Security Warning

This app is a proxy between your computer and any Geminispace origin server. Although we promise not to do anything shady, you should use a real Gemini client if you want verifiable TLS encryption.

See our privacy policy for more info.

gemini-proxy v1.0.0

Here's Johnny!

gemini-proxy is a project of obsessivefacts.com
Contact: henriquez@protonmail.com

Error

This proxy only supports Gemini Protocol addresses.