Featured Posts

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

Read more

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

Read more

Simple Bash Script to Fix Account Permissions This is a simple bash script I wrote to fix the permissions and ownership of files within a cpanel account. To use, simply copy the script your server, chmod 755, and pass the usernames as arguments: ./fixperms...

Read more

Re-Installing Auxiliary cPanel Software Cpanel has a lot of supporting software that you may be using on your server. In case something goes amiss, here is a list of scripts that reinstall cpanel-provided software on your system. For most all...

Read more

10 Free Monitoring Solutions to Consider Server and network monitoring can be crucial to a host's success. I mean, how embarrassing is it when your customers are aware of downtime before you are? You don't have to pay big bucks or spend loads...

Read more

The cPanel Admin Rss

Installing and Configuring Dovecot

Posted by Vanessa | Posted in Misc | Posted on March 26, 2010

0

Enabling Dovecot

You can convert a server from cppop or Courier IMAP to dovecot by running the following command:

/scripts/setupmailserver dovecot

Then set /var/cpanel/cpanel.config values:

maildir=1
mailserver=dovecot

Configuring Dovecot

Most relevant configurations can be made via WHM > Mailserver Configuration.

To customize the Dovecot configuration file in a way that the WHM configuration interface doesn’t allow, use one of the following methods:

If the directive you wish to change is already present in the template file, simply provide a value in the  main datastore. For example, to change the “lock_method” to “dotlock” add a line like this to /var/cpanel/conf/dovecot/main:

lock_method: dotlock

After making this change run /scripts/builddovecotconf and the configuration file will be updated.

If the directives you want to use in the dovecot.conf file do not exist in the template, copy the /var/cpanel/templates/dovecot1.1/main.default  (folder name may vary per version) template file to one named main.local. Make the modifications to main.local then run /scripts/builddovecotconf to regenerate the final configuration file. Your new template will be used each time the Dovecot configuration file is rebuilt in the future.

When using this method please note that updates to the dovecot binaries may require matching updates to the dovecot template file. The dovecot update system does not touch the main.local template in any way, and it is the responsibility of the administrator to reconcile cPanel’s template changes in main.default with the site specific main.local template.

A useful command when customizing the Dovecot configuration file is dovecot -n. This outputs the configuration being used by the current Dovecot process. Using this, you can verify that Dovecot is using all the directives you added to the configuration.

Understanding Courier IMAP and Maildir

Posted by Vanessa | Posted in Misc | 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)