Inconvenient Signature Requirements
Jens John
lists at 2ion.de
Tue May 5 12:47:42 UTC 2020
On Mon, 4 May 2020, at 22:54, Kevin Monceaux wrote:
> My employer is trying to force me to downgrade to Outlook. One of the
> powers that be came up with the brilliant idea of having a standard company
> signature, with logo, specific font requirements, etc. Is there any way to
> include such a signature in e-mails sent from mutt? Sadly, I suspect I
> already know the answer.
Note that in order to include such a signature, you'll also need to send the email as text/html. When composing a text/plain email and sending it, you then seem to need to generate a text/html MIME object and insert it into a multipart/alternative container. The recipient then will have the choice and see either the corporate design HTML or plain text (MUA will likely prefer the HTML version).
Current mutt has a convenient option for this, $send_multipart_alternative:
> If set, Mutt will generate a multipart/alternative container and an alternative part using the filter script specified in $send_multipart_alternative_filter. See the section “MIME Multipart/Alternative” (alternative-order).
You should be able to get done what you want by implementing a $send_multipart_alternative_filter (for the protocol see man muttrc) that converts the message to proper HTML markup (including <p>) and includes the signature snippet. If the signature contains image data, it is possible to inline the image data into the HTML by using the src=data:image/jpeg;base64 attribute of the <img> tag. This saves you from having to inject extra attachments with certain content dispositions into the message, and allows you to keep the filter clean from side effects.
This could be done real quick using Python; though I can also think of getting this done elegantly using pandoc: You'd specify the input format to be markdown, rst or similar, and pandoc will then emit HTML markup with paragraph markers etc, and your signature can be appended to the output file using a footer. Using pandoc with a HTML5 template file would be even simpler than piling up the command line switches; the template could look as simple as (first two lines are $send_multipart_alternative_filter protocol)
> text/html
>
> $body$
> $for(include-after)$
> $include-after$
> $endfor$
and as part of the include-after, pandoc will append any HTML snippet(s) you specify using --include-after-body= to the output as-is. Since pandoc works fine with reading from stdin and writing to stdout, this could make for a clean solution. pandoc has documentation as good as mutt so it should be easy to find your way around it. You'd have two changes: implementing the filter, and possibly a change in style how you format your messages (because Pandoc needs a recognizable markup input format) to match markdown, rich structured text, asciidoc etc.
More information about the Mutt-users
mailing list