[neomutt-users] Dynamically controlling sendmail command

Jakub Jindra jakub.jindra at jakubjindra.eu
Fri Feb 14 18:35:33 CET 2020


Create two config files:

~/.neomuttrc/sendmail.mimebellish:
macro index,pager ,. \
"<enter-command>set sendmail=$HOME/.config/mutt/scripts/sendmail<enter>\
<enter-command>set my_sendmail=mimebellish<enter>\
<enter-command>source ~/.neomuttrc/sendmail.msmtp<enter>
set status_format="YOUR INDEX FORMAT $my_sendmail"


~/.neomuttrc/sendmail.msmtp:
macro index,pager ,. \
"<enter-command>set sendmail=/path/to/msmtp<enter>\
<enter-command>set my_sendmail=msmtp<enter>\
<enter-command>source ~/.neomuttrc/sendmail.mimebellish<enter>"
set status_format="YOUR INDEX FORMAT $my_sendmail"

each macro changes sendmail variable, sets my_sendmail variable which 
can be later displayed in status_format and sources other file so macro 
is rewritten.

You still need two things:
1) somehow set sendmail variable after neomutt starts
2) source the corresponding file

To your main config add:
set sendmail=$HOME/.config/mutt/scripts/sendmail
source  ~/.neomuttrc/sendmail.mimebellish

I believe you already have the first line. The second is necessary to 
define the macro for toggling.

On 2020-02-14 11:09, Adrian Petrescu wrote:
> I prefer sending/receiving emails in plain-text, but due to necessity I
> use a variant of the MIMEmbellish script [1] (which basically just
> passes it through Pandoc and generates a multipart email with HTML). So
> my sendmail variable in neomutt looks like this:
> 
>     set sendmail = "$HOME/.config/mutt/scripts/sendmail"
> 
> And that sendmail script just does:
> 
>     ~/.config/mutt/scripts/MIMEmbellish | msmtp "$@"
> 
> (I would rather not do this, but considering how Gmail doesn't respect
> `format=flowed` I really sometimes must.)
> 
> However, there are certain situations where sending a multipart is _not_
> necessary (like messages to mailing lists such as this one, or to
> certain @gnu.org 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, _or_ 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).
> 
> However, I cannot figure out how to do this within the limited
> expressiveness of muttrc. I can't even seem to be able to `set` 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.
> 
> (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)
> 
> 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?
> 
> Thanks!
> 
> 
> [1]: https://nosubstance.me/post/mutt-secret-sauce/#mimembellish-the-email-embellisher
> 
> 
> -- 
> Adrian

-- 
Jakub Jindra
Mobile: +420732114225


More information about the neomutt-users mailing list