17

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

justintime
  • 3,201
  • 5
  • 29
  • 33
  • 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.) – u1686_grawity Jun 21 '10 at 16:20

4 Answers4

18

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.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • 1
    This only works across IMAP (i have reworded my question). I wonder if I ought to be using `maildirmake -f` – justintime Jun 21 '10 at 08:26
  • @justin: Posted other answer. – u1686_grawity Jun 21 '10 at 09: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 IMAP**s** (bug I should probably report). – Cloud Jul 07 '17 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. – Anthony Geoghegan May 24 '21 at 15:16
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'.)

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • 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 04 '19 at 17:23
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.

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.

Ramhound
  • 41,734
  • 35
  • 103
  • 130
H. Rittich
  • 261
  • 2
  • 3