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.
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)
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)
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)
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’ .
Here’s a sample passwd file:
Similar to the /etc/password on the server, the file contains some critical pieces of information. From left to right:
- 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)
There is a script in cPanel to attempt to fix user mail permissions, and is generally safe to run:
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.