==== Configuration Changes Needed When Using Maildir ====

If you forward your mail from the SDF cluster using a forward as described in the [[http://sdf.org/?tutorials/metaarray|MetaArray]] tutorial, you may have to update your mail client's configuration, as mbox format is used there. If you use procmail, for example, .procmailrc configuration will be slightly different. Lockfiles are not needed in recipes (the trailing ':' after the zero), and directories are used as destinations for mail. Some of the environment variables are different, as well:

  ORGMAIL=/meta/mail/USERNAME
  MAILDIR=/meta/LETTER/USERNAME/Maildir
  PATH=/usr/pkg/bin:/usr/local/bin:/usr/bin:/bin

  :0
  .inbox/

The above will send all mail by default to the directory '~/Maildir/.inbox' (just replace USERNAME with your own user name and LETTER with the first letter of your user name).

Here is a .forward that works with procmail on the MetaArray:

  "|exec /usr/pkg/bin/procmail -f-||exit 75 #USERNAME"

Again, replace USERNAME as appropriate.

If you use mutt, your .muttrc will need to be updated. Here is a minimal maildir config you can incorporate into an existing .muttrc. Note the two 'set spoolfile' lines - the commented one will tell mutt to pull from your system mail spool, however the next, uncommented one that references the '.inbox/' directory will work with the .procmailrc snippet, above. The '.Sent' and '.Drafts' folders are just standard folder names that are compatible with most IMAP implementations, but if you don't use IMAP they can be named anything.

  #set spoolfile="/meta/mail/USERNAME"
  set spoolfile="~/Maildir/.inbox/"
  set folder="~/Maildir/"
  set mbox_type = Maildir
  set mask="!^\\.[^.]"
  set record="+.Sent"
  set postponed="+.Drafts"

  mailboxes `echo -n "+ "; find ~/Maildir -maxdepth 1 -type d -name ".*" -printf "+'%f' "`
  macro index c "<change-folder>?<toggle-mailboxes>" "open a different folder"
  macro pager c "<change-folder>?<toggle-mailboxes>" "open a different folder"
  macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
  macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"

The changes to the mailboxes command and c/C/M macros allow mutt to work with maildir folders, even if the folder names change at some point.

==== Converting Mbox to Maildir ====

If you want to convert your existing mbox-style mailboxes to maildir format, you can use 'mbox2maildir' to do so. The syntax for using it is as follows:

  mbox2maildir [mbox file] [maildir directory]

The maildir directory will be created if it does not exist. As an example, let's say I have copied the mbox file for the gopher mailing list from iceland to ma, and copied it to ~/mail/gopher (where it is on iceland). I would then run the following:

  mbox2maildir ~/mail/gopher ~/Maildir/.lists.gopher

Once run (no errors should be displayed), you can verify the contents of the new maildir directory:

  slugmax@ma:~> ls -la ~/Maildir/.lists.gopher/
  total 40
  drwx------ 5 slugmax arpa  4096 May 14 14:16 .
  drwx------ 5 slugmax arpa  4096 May 14 14:16 ..
  drwx------ 2 slugmax arpa 24576 May 14 14:16 cur
  drwx------ 2 slugmax arpa  4096 May 14 14:16 new
  drwx------ 2 slugmax arpa  4096 May 14 14:16 tmp
  slugmax@ma:~> ls -la ~/Maildir/.lists.gopher/cur/
  total 3472
  drwx------ 2 slugmax arpa  24576 May 14 14:16 .
  drwx------ 5 slugmax arpa   4096 May 14 14:16 ..
  -rw------- 1 slugmax arpa   3452 May 14 14:16 1337019395.6264.mbox:2,S
  -rw------- 1 slugmax arpa   5131 May 14 14:16 1337019396.6264.mbox:2,S
  -rw------- 1 slugmax arpa   4094 May 14 14:16 1337019397.6264.mbox:2,S
  ...

You can see that mbox2maildir has converted each message in the mbox file to its own file and placed each in the maildir-standard 'cur' sub-directory.

==== Converting Maildir to Mbox ====

As you might guess, converting maildir-format folders to mbox is done by the 'maildir2mbox' utility. It operates using environment variables, not command line options, so to be clear it might be best to specify them with the command:

  MAILDIR=~/Maildir/.lists.gopher/ MAIL=~/mail/gopher MAILTMP=~/tmp/foo maildir2mbox

Note that the file specified by MAILTMP and the one specified by MAIL must be on the same filesystem. When this command is run, you should see the ~/mail/gopher mbox file in place:

  slugmax@ma:~> ls -l ~/mail/gopher
  -rw------- 1 slugmax arpa 2680127 May 14 14:34 /meta/s/slugmax/mail/gopher
  slugmax@ma:~>

$Id: maildir.html,v 1.5 2019/07/23 01:30:22 slugmax Exp $