16

I want to create a new folder from within Mutt. I use Maildir format to store the folders on the machine I am running Mutt on.

(I also view the mail remotely using courier IMAP but this doesnt involve Mutt)

Edited to clarify role of IMAP

1
  • I'm using Dovecot, and it supports activating the imapd directly from shell; for example, dovecot --exec-mail imap, which can be used for Mutt's set tunnel=. Maybe Courier has a similar thing too? It would allow mailbox creation within Mutt. (/usr/lib/courier/imap might be enough.)
    – user1686
    Jun 21, 2010 at 16:20

4 Answers 4

13

If Mutt cannot create maildirs directly, it is easy to do it yourself. A "Maildir" format mail directory has nothing special except for three subdirectories cur/, new/ and tmp/ inside.

Assuming that your mail is kept under ~/mail/, a folder named "Something" would be created like:

  • For the Maildir++ layout used by Courier and Dovecot:

    mkdir -p ~/mail/.Something/{cur,new,tmp}
    

    (Note the leading dot – yes, this basically means subfolders are stored as hidden directories...)

    Equivalent to:

    mkdir ~/mail                    (implied by `-p`)
    mkdir ~/mail/.Something         (implied by `-p`)
    mkdir ~/mail/.Something/cur     (from brace expansion)
    mkdir ~/mail/.Something/new     (from brace expansion)
    mkdir ~/mail/.Something/tmp     (from brace expansion)
    
  • For the "filesystem" layout used by some other IMAP daemons:

    mkdir -p ~/mail/Something/{cur,new,tmp}
    

If you want a folder hierarchy "Archive" / "2010" / "06":

  • In Courier's layout, the folder would be named Archive.2010.06:

    mkdir -p ~/mail/.Archive.2010.06/{cur,new,tmp}
    
  • In the "filesystem" layout, it would be Archive/2010/06:

    mkdir -p ~/mail/Archive/2010/06/{cur,new,tmp}
    

(Terminology: mail clients keep messages in 'folders', and the filesystem stores everything in 'directories'.)

1
  • 2
    Mutt will create a new mailbox when saving a message into a non-exiting one. When setting set mbox_type=Maildir in the configuration file, it will use the Maildir format.
    – H. Rittich
    Feb 4, 2019 at 17:23
17

c (change-folder), ? (list), Shift+C (create-mailbox).


This works with Gmail but only in the single directory view, and not in the "all folders" view.

Also, if you want a space in the directory name, you need to escape it via Ctrl+V, Space.

4
  • 1
    This only works across IMAP (i have reworded my question). I wonder if I ought to be using maildirmake -f
    – justintime
    Jun 21, 2010 at 8:26
  • @justin: Posted other answer.
    – user1686
    Jun 21, 2010 at 9:57
  • @grawity Agreed, edit has nothing to do with TLS, but mutt seems to have a quirk when creating a folder in the "all folders" view, and succeeds when utilizing a IMAP vs IMAPs (bug I should probably report).
    – Cloud
    Jul 7, 2017 at 13:06
  • I rarely create folders on IMAP servers but when I do, they usually have spaces in their name so I've been back to this answer more than once after discovering that escaping with a backslash or quotes doesn't work. May 24, 2021 at 15:16
7

I usually just save some email to new not-yet-existing folder, and mutt creates the folder for me.

For me it's pretty intuitive, as there is no point in having folder without mails in it, so I just create it by saving there first mails that should go there.

3
  • How do you do that - if you type M it then gives me a list of existing mailboxes. Thanks
    – justintime
    Jun 24, 2010 at 10:09
  • "M"? I don't know what "M" does. I just press "s" on index of maildir, and then I can type my requested folder name.
    – user7385
    Jun 24, 2010 at 11:48
  • @justintime s Mar 27, 2014 at 8:27
4

If you save a mail into a non-existing location, mutt creates a new mailbox for you. The type of the mailbox is determined by the state of the variable mbox_type. Hence, to create a Maildir within mutt, you proceed as follows.

Open your .muttrc file and add the line

set mbox_type=Maildir

This line ensures that mutt creates new mailboxes in the Maildir instead of in the Mbox format.

Then, start mutt and select a message that you want to save into a new folder. Press s to save and enter the path of the new mailbox (without a slash at the end) and press enter. Mutt will create a new Maildir and saves the message into the newly created mailbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.