I receive GnuPG-encrypted (and signed) e-mails through an MS Exchange server. Unfortunately, the exchange server messes up the GPG format, such that mu4e cannot decrypt correctly.

This is a known issue with MS Exchange servers. For instance, Thunderbird-Enigmail pops up a message, "do you want to repair this message", and offers to repair the message. This changes some MIME headers and contents, and then the e-mail can be decrypted correctly.

I wrote a small Python script, which makes similar changes to files containing e-mails in a Maildir directory, which is synced with an IMAP server via offlineimap.

Now, whenever I open an encrypted e-mail in mu4e that cannot be encrypted, I want to run the Python script on the corresponding file, and then re-load it. How can I do this in Emacs Lisp?

Or, is there any other, simple solution to mimic the behaviour of Thunderbird's Enigmail plugin to repair e-mails messed up by Exchange servers?

1 Answer 1


From the view buffer press a R and see if that works for you.

(defun mu4e-repair-file (msg)
  (let ((path (mu4e-message-field msg :path))
        (maildir (mu4e-message-field msg :maildir)))
    (shell-command (format "yourscript %s" path))
    (mu4e-refresh-message path maildir)))

(add-to-list 'mu4e-view-actions
             '("Repair file" . mu4e-repair-file))
  • I can confirm that this works like a charm. Amazing, thank you very much!
    – user64060
    Commented Mar 29, 2019 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.