Understanding Dovecot IMAP and Maildir

3/5 - (5 votes)

Maildir (run by Courier IMAP or Dovecot) is a mail format used in conjunction with an MTA to store email on the server as separate files within folders. This post covers Courier IMAP as a service, not in terms of mail client usage.

Directory Structure

A user’s email is store in ”’/home/user/mail/<domain>/<emailuser>/…”’. Below is a sample directory structure of an email account:

  • /home/username/mail (mail folder)

    • /domain.com (domain)

    • admin (email user)

    • maildirsize (quota/usage summary, expendable)

    • cur (default inbox for read email)

    • new (default email for unread email)

    • Drafts ( sample folder )

      • – cur (read email)

      • – new (unread email)

  • /home/username/etc

    • /domain.com (domain)

      • passwd (contains email account list and UIDs, similar to /etc/passwd)

      • shadow (contains email passwords, similar to /etc/shadow)

      • quota (contains email account quota info)

Folders

So basically, each email user has its own folder, each containing the main inbox (cur/new), and separate email folders. Each separate inbox folder also contains a ”’cur”’ and ”’new”’ folder.

  • cur – read email
  • new – unread email

Email that is marked as read by the IMAP client (outlook, etc) is moved from ‘new’ to ‘cur’ .

Etc Files

Here’s a sample passwd file:

admin:x:510:510::/home/user/mail/domain.com/admin:/bin/bash
support:x:513:513::/home/user/mail/domain.com/support:/bin/bash

Similar to the /etc/password on the server, the file contains some critical pieces of information. From left to right:

  • username
  • password (x indicates the password is in a shadow file)
  • UID (should match main user’s UID in /etc/password)
  • GID (should match main user’s GID in /etc/password)
  • home folder (location of the email account’s mail folders)
  • shell (not relevant)

Permissions

There is a script in cPanel to attempt to fix user mail permissions, and is generally safe to run:

/scripts/mailperm

The permissions should be as follows:

– /home/user/etc (user:mail, 755)
– domain.com (user:mail, 770)
– passwd (user:mail, 644)
– shadow (user:mail, 644)

The other permissions can be 755 user:user, as those files don’t affect email delivery.

 

– /domain.com (domain)

– /admin (email user)

– maildirsize (quota/usage summary, expendable)

– cur (default inbox for read email)

– new (default email for unread email)

– Drafts ( sample folder )

– cur (read email)

– new (unread email)

– /home/username/etc

– /domain.com (domain)

– passwd (contains email account list and UIDs, similar to /etc/passwd)

– shadow (contains email passwords, similar to /etc/shadow)

– quota (contains email account quota info)

3 Comments

  1. Dinceroz81 Reply

    hi,
    copy the directadmin mail folder to the cpanel mail folder, the inbox mailer has arrived but we cannot see the subfolders created by the user manually.

    thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Log in