Linux

mutt: how to automatically change the sender based on the current folder

The mutt e-mail client allow using a trivial configuration to automatically change the sender of the email (the From header) based on the current active folder.

The configuration option that allow this is “folder-hook“. It accept two parameters:

  1. the folder name that should match, as regular expression
  2. a mutt command , we’ll change the From header in our case

At the top of our list we’ll set the default folder and after that all the other folders that you wish to hook:

folder-hook .* "my_hdr From: Antonio Gallo <agx@xxx.it>"
folder-hook MITICI "my_hdr From: Aiuto Mitici <aiuto@yyyyy.it>"
folder-hook AXNET "my_hdr From: Antonio Gallo <antonio.gallo@zzzzz.it>"
folder-hook ILS "my_hdr From: Antonio Gallo <agx@iiiii.it>"
folder-hook LUG "my_hdr From: Antonio Gallo <agx@lllllll.it>"
folder-hook LUG-LATINA "my_hdr From: Antonio Gallo <agx@latinalatina.it>"
folder-hook FREEBSD "my_hdr From: Antonio Gallo <freebsd@bpbpbpbp.org>"

I also added some more custom headers to my mutt config file to make it more usefull:

my_hdr X-Disclaimer: Please visit http://www.badpenguin.org/
my_hdr X-Operating-System: Bad Penguin GNU/Linux 0.99.7