<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="ProgId" content="Word.Document">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Dynamically controlling sendmail command</title>
  <style type="text/css">
  </style>
</head>
<body>
<p>I prefer sending/receiving emails in plain-text, but due to necessity I use a variant of the MIMEmbellish script <a href="https://nosubstance.me/post/mutt-secret-sauce/#mimembellish-the-email-embellisher">1</a> (which basically just passes it through Pandoc and generates a multipart email with HTML). So my sendmail variable in neomutt looks like this:</p>
<pre><code> set sendmail = "$HOME/.config/mutt/scripts/sendmail"</code></pre>
<p>And that sendmail script just does:</p>
<pre><code> ~/.config/mutt/scripts/MIMEmbellish | msmtp "$@"</code></pre>
<p>(I would rather not do this, but considering how Gmail doesn’t respect <code>format=flowed</code> I really sometimes must.)</p>
<p>However, there are certain situations where sending a multipart is <em>not</em> necessary (like messages to mailing lists such as this one, or to certain <span class="citation" data-cites="gnu.org">@gnu.org</span> email addresses where I worry the message won’t even be read if there’s HTML involved 😉). Therefore I would like to have some sort of manual way to toggle, prior to composing or sending a message, the sendmail command, <em>or</em> alternatively to pass some sort of variable to my sendmail script that would allow it to decide whether to invoke MIMEmbellish itself based on my manual toggle and/or the recipient(s).</p>
<p>However, I cannot figure out how to do this within the limited expressiveness of muttrc. I can’t even seem to be able to <code>set</code> a custom variable that I could manually toggle with a macro and just pass as an arg to my sendmail script. I suppose some sort of macro using really complicated format string operations to toggle sendmail itself back and forth might work, but that seems terrifying.</p>
<p>(BONUS points if I could also somehow display the current state of this toggle in the send confirmation screen, so I could just double-check whether I’m in the right mode before committing)</p>
<p>Am I missing some straightforward way to achieve what I’m looking for? Anyone else perhaps have a totally alternative way to accomplish the same goal?</p>
<p>Thanks!</p>
<p>– Adrian</p>
</body>
</html>