mutt and deleting email via protonmail bridge

The Problem

I haven’t deleted an email message since 2018. This was not my intention, but deleting messages from the INBOX doesn’t actually delete messages when you’re using the ProtonMail Bridge. I have a lot to delete, and delete wasn’t working. Over the course of the last week I have discovered the following:

The Solution

Trash Option

The trash setting in conjunction with folder hooks works pretty well.

From the mutt manual:

3.396. trash

Type: path
Default: (empty)

If set, this variable specifies the path of the trash folder where the mails
marked for deletion will be moved, instead of being irremediably purged.

NOTE: When you delete a message in the trash folder, it is really deleted, so
that you have a way to clean the trash.

This needs to be set to the Trash folder on the IMAP server. IE:

set trash=+Trash

I presume that + makes it use the IMAP server Trash folder instead of a local directory. I’m having trouble locating the manual section that addresses this.

Folder Hooks

Setting the trash option is not enough by itself. With this setting on, attempting to delete from the IMAP Trash folder will result in copying the message to the IMAP Trash folder. To get around this, folder hooks are needed.

From the Manual:

9. Setting Variables Based Upon Mailbox

Usage:

folder-hook [!]regexp command

It is often desirable to change settings based on which mailbox you are
reading. The folder-hook command provides a method by which you can execute any
configuration command. regexp is a regular expression specifying in which
mailboxes to execute command before loading. If a mailbox matches multiple 
folder-hooks, they are executed in the order given in the .muttrc.



Note

Settings are not restored when you leave the mailbox.

I use the following:

folder-hook . 'set trash=+Trash'
folder-hook =Trash 'unset trash'

The result here is that upon entering any folder (even the Trash) the trash option gets set. But then there is an additional hook, that upon entering the Trash folder will unset the trash option. The end result is that using the delete option in any folder (except the Trash) will copy the message to the Trash before trying to delete it form the current folder. If the current folder is the Trash, then the message will just get expunged.

Some quirks:

The INBOX will not complain when a message is expunged, but it also doesn’t delete that message from the ProtonMail server. Until the trash is emptied, the message will simultaneously exist in the Trash and the All Mail folder.

Attempting to delete from the All Mail folder will correctly copy to the trash, but then an error will be generated about the expunge failing. It may or may not cause the message to disappear temporarily from All Mail, but refreshing/reloading/whatever will reveal that the message is still present in All Mail and only when the message is deleted and expunged from the Trash will it also be removed form All Mail.

More Mutt Docs

The man page for mutt is somewhat sparse, but there is an html manual. The path might even be mentioned in the man page, it was on my NixOS install. Only problem is that it’s an html page, but there’s a fix for that! I use w3m on the manual html page in a fashion very similar to how I dump html emails to text, except less automatic.

The following would do it at the command line:

w3m -B -o display_link_number=1 -I utf-8 -T text/html  < manual.html > output.txt

Of course that requires providing the full path to the manual. Except I open the html page in Neovim, hit (shift) V on the first line, hit (shift) G, and then use a very similar command:

:'<,'>!w3m -B -o display_link_number=1 -I utf-8 -T text/html

Tags

=> #index | #protonmail | #mutt

Navigation

=> index | tags | prev ⏰

created: 2025-01-29

(re)generated: 2025-01-29

Proxy Information
Original URL
gemini://thatit.be/2025-01-29-12-49-48.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
432.87509 milliseconds
Gemini-to-HTML Time
1.75092 milliseconds

This content has been proxied by September (3851b).