| Home » Categories » Multiple Categories |
How To Set Up a Postfix Email Server with Dovecot: Dynamic Maildirs and LMTP |
|
Article Number: 231 | Rating: Unrated | Last Updated: Tue, Sep 23, 2025 at 11:22 PM
|
PrefaceThis tutorial is based on How To Set Up a Postfix E-Mail Server with Dovecot and picks up where the first part ended.
In this article, we will divorce mailboxes from system accounts using dovecot’s LMTP server as delivery mechanism, as well as use postgresql to keep user records. No more mail will be delivered to the standard linux mailboxes. Like the first guide, this tutorial is based on Debian 7 wheezy, Postfix 2.9, and dovecot 2.1 (+ Postgresql 9.1). PackagesInstall postgresql:
dovecot in version 2.1 should already come with pgsql enabled. If you’re on a system where dovecot is modularised, run
to install the needed modules. Postgres Database SetupAdjust this for your needs if you already have a postgres setup running! But from a fresh postgres install, let’s set up authentication so that we can give dovecot access to the database. Add the following to/etc/postgresql/9.1/main/pg_ident.conf:
And the following to
Then reload postgresql (
You can then add virtual mailboxes like this, starting from a rootshell:
Administration Interface (optional)If you don’t want to use the command line interface to maintain the mail database, you can set up an administration interface. Let’s first add a database user that is only allowed to edit the mail databse. Go back to/etc/postgresql/9.1/main/pg_hba.conf and add this line just under the peer authentication line you added earlier:
This will allow local socket connections on port 5432. (The default port for postgres) Add the database user:
Give the user the privileges to edit the mail database:
You can now use an administration interface like pgAdmin that is capable of using SSH tunneling to directly connect to the database, or you could set up something like phpPgAdmin. Dovecot SetupWe need to connect dovecot to the database and set up the LMTP server. Set up a new user (dovecot will refuse to handle mail without a system user set up for it) and directory for maildirs first: (you could use /var/mail, but that traditionally uses the mbox format, while we’re going to be using the superior maildir format).
Now save the following configuration as
Make sure it is owned by root and chmodded 600. Now open
Change the protocols stanza to
and add the lmtp service socket and some lmtp protocol settings:
The mail_location stanza is now superfluous and can be removed. PostfixWe now need to tell postfix to deliver mail directly to dovecot. Open/etc/postfix/main.cf and add
to the end. Now we need to set the database config for postfix. Create the file
Then create the file
Now amend the alias_maps line in main.cf to read
and the local_recipient_maps line to read
In whole, your main.cf should look similar to this:
Finishing UpNow simply reload:
And you’re set! Test your setup as you did after the first article, and make sure mail to |
Attachments
There are no attachments for this article.
|
How To Use SuExec in Apache to run CGI Scripts on an Ubuntu
Viewed 4437 times since Mon, Dec 30, 2013
How To Install And Run A Node.js App On Centos 6.4 64bit
Viewed 11196 times since Sun, Dec 29, 2013
How To Use a Simple Bash Script To Restart Server Programs
Viewed 3963 times since Fri, Dec 27, 2013
How To Install and Use PostgreSQL on Ubuntu 12.04
Viewed 7041 times since Mon, Dec 30, 2013
How To Install an Upstream Version of Node.js on Ubuntu 12.04
Viewed 3406 times since Sun, Dec 29, 2013
An Introduction to Linux Basics
Viewed 7215 times since Fri, Dec 27, 2013
How To Create a SSL Certificate on Apache for Ubuntu 12.04
Viewed 4037 times since Mon, Dec 23, 2013
The Basics of Using the Sed Stream Editor to Manipulate Text in Linux
Viewed 7294 times since Fri, Dec 27, 2013
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Arch Linux
Viewed 5358 times since Fri, Dec 27, 2013
What is FTP and How Is It Used?
Viewed 3168 times since Fri, Dec 27, 2013
|
