I would like to configure Mutt so that the default save folder changes depending on the current folder:

  • When reading messages in the folder =account1/Unsorted or =account1/Important or any other sub-folder under =account1/, I'd like the default save folder (the one suggested when pressing s in the message index) to be =account1/INBOX.

  • Likewise, for sub-folders of =account2/, I'd want the default save folder to be =account2/INBOX, etc.

How may I configure Mutt to do this?

  • It appears save-hook would have been useful, if it had a way of matching against the folder name (I don't think it has).
  • It appears folder-hook would have been useful, if it had a way of setting the save folder, but there is no save folder setting to set with the hook (there's record, but that's for outgoing messages).

1 Answer 1


Update: Reportedly, the following two lines were used

folder-hook +account1 unhook save-hook
folder-hook +account1 save-hook . +account1/INBOX

repeated for each account.

Mutt, as you know, is configured by .muttrc file. Look at man muttrc, the patterns at all others is there. I also do not see a folder pattern there but searching for save I found elsewhere

 Note that these expandos are supported in "save-hook", "fcc-hook" and "fcc-save-hook", too.

and above that

              %b     filename of the original message folder (think mailbox)
              %B     the list to which the letter was sent, or else the folder name (%b).
              %O     original  save  folder where mutt would formerly have stashed the message: list name or
                     recipient name if not sent to a list

Some of them could potentially be used, but I do not see in patterns any way how to match against a fixed string and not against the message.

Use can make procmail (or whatever is messing with your incoming mail) to add a custom header line and use -h to test for it.

I think your solution will be using

     folder-hook [!]regexp command
              When  mutt enters a folder which matches regexp (or, when regexp is preceded by an exclamation
              mark, does not match regexp), the given command is executed.

              When several folder-hooks match a given mail folder, they are executed in the order  given  in
              the configuration file.

May be something like

folder-hook account1 unhook *
folder-hook account1 save-hook ~A   =account1/INBOX
folder-hook account1      save-hook  ".*"  =account1/INBOX
folder-hook ^=account1.*  save-hook  ........... ???

UPDATE: Reportedly, the following two lines were used as solution (and seem to work)
folder-hook +account1 unhook save-hook
folder-hook +account1 save-hook . +account1/INBOX
# repeated for each separate account
# Note: We know the documentation for folder-hook says "regexp", but using +account (for some given account) seems to work too for whatever reason

It is unlikely that the most recent save-hook take precedence, so I added unhook (change it to unhook save-hook or whatever you test to work)

    unhook [ *  | hook-type ]
              This  command will remove all hooks of a given type, or all hooks when "*" is used as an argu-
              ment.  hook-type can be any of the -hook commands documented above.

The following info might be useful for other users who have simpler needs and somehow came to this page:

              Type: boolean
              Default: no

              If set, mutt will take the sender's full address when choosing a default folder for  saving  a
              mail. If $save_name or $force_name is set too, the selection of the Fcc folder will be changed
              as well.

              Type: boolean
              Default: no

              This  variable  controls how copies of outgoing messages are saved.  When set, a check is made
              to see if a mailbox specified by the recipient address exists (this is done by searching for a
              mailbox  in  the  $folder  directory with the username part of the recipient address).  If the
              mailbox exists, the outgoing message will be saved to that mailbox, otherwise the  message  is
              saved to the $record mailbox.

              Also see the $force_name variable.

An example:
set save_address=yes

Please tell me and others how you solved the problem.

  • Unhooking the save hook and setting a new one in two folder hooks seems to work. So basically, folder-hook +account unhook save-hook followed by folder-hook +account save-hook . +account/INBOX. As far as I can see right now, using only these two commands (repeated for each separate account) seems to do the trick. Much thanks! (NOTE: I know the documentation for folder-hook says "regexp", but using +account (for some given account) seems to work too for whatever reason.)
    – Kusalananda
    Sep 7 at 13:48
  • I do not understand the plus in '+account', never mind. I warn about the dot after save-hook -- you require non-empty From header or something, which depends on default_hook variable. I recomend .* if it works. ~A would be even better (if it works)
    – minorChaos
    Sep 7 at 14:31
  • The plus sign is the same as the equal sign to denote a folder under the main mail store. I wasn't thinking about it when I used = in the question, but I actually use + everywhere. It shouldn't matter. The lone dot should match as long as the message is non-empty. I usually have non-empty messages in my mailbox. Having an empty message is spectacular enough that I'd be quite ok with almost anything happening :-)
    – Kusalananda
    Sep 7 at 15:03
  • " as the message is non-empty " --- no, because documentation says regexp is matched as specified in default_hook variable. The sender and similar. You may argue that the sender is usually non-empty, which is true.
    – minorChaos
    Sep 7 at 15:43
  • By "the message" I mean header+body, the whole thing, but I see what you mean by the default_hook. This just means that matching on a dot will mean the message is from or to somebody (to someone from me, or to me from somebody), which sounds like a reasonable assumption to me.
    – Kusalananda
    Sep 7 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .