Re: filtering headers from forwarded messages

Subject: Re: filtering headers from forwarded messages

Date: Wed, 30 Dec 2020 12:46:02 +0200

To: Daniel Kahn Gillmor, Notmuch Mail


From: Teemu Likonen

* 2020-12-24 12:56:09-0500, Daniel Kahn Gillmor wrote:

>> On Wed 2020-01-08 10:25:50 -0500, Daniel Kahn Gillmor wrote:
>>> Thanks for the pointer! it looks like
>>> message-forward-{ignored,included}-headers should do (roughly) what
>>> i want. I'll try them out.

> Hm, it now looks to me like message-forward-ignored-headers isn't
> working since i upgraded to emacs 27.1. In particular, since:

I don't know any automatic way to remove headers from an email message
that is stored as a MIME part.

When a forwarded message is stored as inline text (setq
message-forward-as-mime nil) then the message is rendered at the time of
composing the message. Unnecessary headers are removed, character
encodings are decoded etc.

When the forwarded message is stored as MIME type "message/rfc822" (setq
message-forward-as-mime t) then the message is meant to be rendered by
the receiver's email program which will decode all necessary headers,
especially MIME headers, convert between character sets and pretty-print
the message's headers and some of the MIME "text/*" parts.

Filtering or editing headers of email MIME part (message/rfc822) can be
tricky: there are message's main headers which tell the "Content-Type"
of the body, and the body can contain different MIME parts with some of
their own headers. If we filter too much or convert between character
sets the message is not proper message/rfc822 part anymore and can't be
rendered correctly.

What about forwarding a message as MIME part which is just "text/plain"
(and not "message/rfc822")? At least this can be done by setting (setq
message-forward-as-mime nil) and manually inserting Emacs MML tags in
the (notmuch-)message-mode buffer:

    C-c RET p text/plain RET

or calling from Lisp code:

    (mml-insert-part "text/plain")

The inserted MML tags need to be put manually around the forwarded
message. With some hackery one could write a semi-automatic function for

/// Teemu Likonen - .-..
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450
signature.asc (application/pgp-signature)
notmuch mailing list --
To unsubscribe send an email to