Configuring Mutt to Use Maildir Format System-wide: Fixing Default Mailbox Location Issues


4 views

After migrating from mbox to Maildir format across our Postfix/Dovecot mail server (with mailboxes stored in ~/Maildir), we encountered an unexpected behavior from Mutt. Despite proper server configuration, Mutt persistently attempts to:

  • Create ~/Mail directories
  • Look for mbox files in /var/mail/
  • Ignore our Maildir specifications

Mutt's default configuration stems from historical Unix mail handling conventions. The key configuration points we need to address:


# Default mbox location (unwanted in our setup)
set mbox="/var/mail/$USER"

# Default folder format (mbox instead of Maildir)
set folder="~/Mail"

To enforce Maildir usage for all users, we'll modify Mutt's global configuration file (/etc/Muttrc or /etc/Muttrc.local):


# Set Maildir as default mailbox format
set mbox_type=Maildir

# Define the correct mail directory
set folder="~/Maildir"

# Disable mbox completely
unset mbox

# Important Maildir-specific settings
set maildir_trash=yes
set maildir_check_cur=yes

For individual users who need additional tweaks, they can add these to their ~/.muttrc:


# Example per-user customization
set record="+/Sent"
set postponed="+/Drafts"
set spoolfile="+/INBOX"

# Optional: Set folder hooks for better organization
folder-hook . 'set from="user@domain.com"'

After implementation, verify with:


mutt -v | grep -E 'mbox_type|folder'

Expected output should show Maildir as the mailbox type and ~/Maildir as the folder location.

If users still encounter problems:

  1. Check folder permissions: chmod -R 700 ~/Maildir
  2. Verify correct Maildir structure (new/cur/tmp subfolders)
  3. Ensure Dovecot is properly configured for Maildir

When migrating from mbox to Maildir format while using Postfix/Dovecot, Mutt's default behavior can conflict with the new mail storage structure. The key symptoms include:

  • Mutt attempting to create ~/Mail directories
  • Persistent searches for mbox in /var/mail/
  • Configuration mismatches for multi-user systems

For Debian-based systems, the proper way to enforce Maildir usage across all users is through Mutt's global configuration file. Here's how to implement it:

# /etc/Muttrc (system-wide configuration)
# Force Maildir format globally
set mbox_type=Maildir
set folder=~/Maildir
set spoolfile=+/Maildir/
set header_cache=~/.hcache
set mail_check=60

To ensure proper synchronization with Dovecot's Maildir implementation, add these specialized settings:

# Dovecot Maildir compatibility
set maildir_trash=yes
set maildir_check_cur=yes
set move=no

Confirm your Postfix main.cf contains these critical Maildir parameters:

# /etc/postfix/main.cf
home_mailbox = Maildir/
mailbox_command = /usr/lib/dovecot/deliver

While the system-wide configuration handles most cases, individual users might need these .muttrc additions:

# ~/.muttrc
# Personal Maildir customizations
set record=+/Maildir/.Sent/
set postponed=+/Maildir/.Drafts/

If mail still appears in /var/mail:

  1. Verify Postfix isn't falling back to mbox:
    postconf -n | grep mailbox_command
  2. Check Dovecot's mail_location:
    doveconf -n | grep mail_location

Ensure proper Maildir permissions system-wide:

# Sample permission fix script
for user in /home/*; do
  chmod -R 700 $user/Maildir
  chown -R ${user##*/}:mail $user/Maildir
done