+++ Sunday 5 January 2025 +++ Export decrypted messages from entire mailbox ============================================= My email is stored on an IMAP server, and I read the mail with Emacs Gnus. One of the IMAP folders contains only GPG-encrypted messages. Although sometimes the subject can help to find a message, it is quite hard to search for a specific message. To make it easier to sift through the messages, I wanted to export the full mailbox to an unencrypted format. Mutt to the rescue ------------------ > All mail clients suck. This one just sucks less. I haven't found a good method with Gnus to export all the encrypted messages in a mailbox to a directory with all the messages in decrypted format. With Mutt, this is easy. In the jail I downloaded the source of Mutt, enabled IMAP and gpgme in ./configure, compiled Mutt, and fired it up. Selecting and exporting message ------------------------------- Start Mutt, connect to the IMAP server, and with `c' open the desired mailbox. First, set the save format to maildir, press : (colon) to go to the command mode, and enter "set mbox_type=Maildir" (without the quotes). Tag all messages with `T .' (shift-T followed by a period) Start to operate on the tagged messages with ; (semi-colon) Enter decode-copy as operation with `M-C' (Alt shift-c) Make sure to choose 'decode-copy' and not 'decode-save', because in Mutt `save' means 'move', and it will mark the messages in the IMAP mailbox with the `delete' flag. Mutt asks for a mailbox name and proposes a name starting with `='. We don't want to store the decrypted messages on the IMAP-server, therefor replace this with the desired directory name, f.e., "decoded-messages" (without the quotes). Without the `=' at the beginning of the name, Mutt will store locally. Mutt will make a local directory with the supplied name. This directory will be in the maildir format, which is great because we want to search for individual messages. When the maildir directory already exists, Mutt will ask if it may append the messages. You can safely say "yes" here, it will just add the messages to the directory. Later, after having received more messages, you can tag the newer messages with a date-range, like: `T ~d 01/02/2025-31/03/2025' to select messages from February 1st to March 31st, again followed by the `; M-C' command. Start searching --------------- The end result is a directory in maildir format, so there will be the sub directories `cur', `new', and `tmp', with all the messages, each in a separate file, in the `cur' sub directory. Now you can search for individual messages, with grep, ripgrep, or, build a search index with recoll. Last edited: $Date: 2025/01/05 11:25:27 $