Featured Posts

Using DKIM with Exim and cPanel Similar to the intentions of SPF records and DomainKeys, DKIM is intended to authenticate a sender by using a public/private key pair to digitally sign email, therefore increasing deliverability. At this...

Readmore

Copy Outgoing Email on a cPanel Server with Exim A common request we get is how a user can automatically BCC outgoing email to another address. This is most often requested by law firms that need to be able to retain copies of communication. Forwarding...

Readmore

Do You Care About Your Customers' Data? I was working a case last week for a new client that's been hosting local business websites for over three years. As with all of my case studies, I did a short survey of the client's infrastructure, processes,...

Readmore

Tips to Reduce Your Customer Support Costs When hosting websites, whether as a mainstream hosting provider, a hobby, or to supplement another service, it's your job to make sure your customers have access to technical support in case they need...

Readmore

Roundcube: MySQL or SQLite? cPanel 11.25 introduces a new feature: The ability to have RoundCube use SQLite instead of MySQL. After benchmarking resource usage and performance, I've come to the conclusion that SQLite is definitely...

Readmore

The cPanel Admin Rss

Understanding Courier IMAP and Maildir

Posted by Vanessa | Tagged under , | Posted on March 23, 2010

1

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/vnessa5/mail/v-nessa.net/admin:/bin/bash
support:x:513:513::/home/vnessa5/mail/v-nessa.net/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, which is safe to run on a VPS or Dedicated server, but should not be run on shared without approval from a system admin:

/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.

The ‘fixperms’ command on the shared servers should fix the permissions of a user’s home folder, including mail and etc.

Converting to Maildir

/scripts/convert2maildir

This will leave the inbox files behind if you’re coming from Mbox, so you can list/remove them with:

find /home/*/mail/* -name inbox -exec ls -la {} \;

- /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)


Liking this article? Share it and spread the word!
  • Print
  • PDF
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts:

Comments (1)

It is also easy to backup and transfer all your websites from one server to another server if you have cPanel installed`::

Write a comment