Home > centOS, Fedora 12, MySQL, Unix/Linux > centOS – Postfix + Postfixadmin + Dovecot

centOS – Postfix + Postfixadmin + Dovecot

Postfixadmin Installation:

        [root@www /]# uname -a
        Linux www..be 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x8 6_64 x86_64 GNU/Linux

1. google download postfixadmin

2. tar xvfz postfixadmin_2.3.tar.gz.tar.gz -C /usr/share/

3. yum install php-imap.i686
        * restart the httpd -k restart

4. vi /usr/share/postfixadmin-2.3/config.inc.php

        config.$CONF['configured'] = true;
        // Database Config
        $CONF['database_type']     = ‘mysql’;
        $CONF['database_host']     = ‘localhost’;
        $CONF['database_user']     = ‘root’;
        $CONF['database_password'] =;
        $CONF['database_name']     = ‘postfix’;
        // Encrypt
        $CONF['encrypt'] = ‘cleartext’; // shamun

5. http://localhost/postfixadmin/setup.php

6. when you make setup password, copy the given line and past in the following file.
        vi /usr/share/postfixadmin-2.3/config.inc.php
        $CONF['setup_password'] = 'b90d3eceb6e475e85e92b04eb5d6cbd1:e80d6fa140cb7ea3a65783e16e7afc3ebdaa712f';

7. you make admin account thats it.

Note important:

8. make a virtual domain like i did: shamun.be

9. make a virtual email like marie@shamun.be

- this will be needed for a test emails, at the end

Postfix Installation:

1. Add user
        [root@www ~]# useradd vmail
        [root@www ~]# id vmail
        uid=501(vmail) gid=501(vmail) groups=501(vmail) context=user_u:system_r:unconfined_t
        [root@www ~]#

2. Install postfix with mysql support (default is without mysql)
        [root@www etc]# vi /etc/yum.repos.d/CentOS-Base.repo
        #[base] and [update] sections of /etc/yum.repos.d/CentOS-Base.repo added
        name=CentOS-$releasever - Plus
        [root@www ~]# yum install postfix
                postfix.x86_64 2:2.3.3-2.1.centos.mysql_pgsql
        [root@www postfix]# postconf -m
        [root@www ~]# whereis postfix
        postfix: /usr/sbin/postfix /etc/postfix /usr/libexec/postfix /usr/share/man/man1/postfix.1.gz

3. vi /etc/postfix/main.cf
        # My edits
        virtual_mailbox_domains = mysql:/etc/postfix/mysql-domains.cf
        virtual_mailbox_maps = mysql:/etc/postfix/mysql-users.cf
        virtual_alias_maps = mysql:/etc/postfix/mysql-aliases.cf
        virtual_mailbox_base = /home/vmail
        virtual_uid_maps = static:501
        virtual_gid_maps = static:501
# [optional] but important in production:
# important, this part of postfix is for incoming emails to receive
# when i send email from hellobello@gmail.com to this@setup.com
# Email bounced and gets fail: The error that the other server returned was: 550 550 5.1.1
# So, put this as following
local_recipient_maps = # leave empty incase you want public and local test get success
inet_interfaces = all # instead of localhost

#[optional] - spamm protect
# Spamm kill
permit_mynetwork= $mynetworks
check_relay_domains = $relay_domains, $inet_interfaces
smtpd_helo_required = yes
smtpd_recipient_restrictions =
 check_client_access hash:/etc/postfix/clients,
 reject_rbl_client cbl.abuseat.org,
 reject_rbl_client pbl.spamhaus.org,
 reject_rbl_client sbl.spamhaus.org,

# test local mail to outside
# test outside mail to inside
# (Test this from shell, that nobody using your box sending emails): telnet relay-test.mail-abuse.org

4. vi /etc/postfix/mysql-domains.cf
# config

host = localhost

user = root

password =

dbname = postfix

table = domain

select_field = domain

where_field = domain

additional_conditions = and backupmx = '0' and active = '1'


# Side work - postfixadmin

# add domains ex: mydomain.com

# add email address ex: me@mydomain.com

5. Test point 4

[root@www postfix]# postmap -q yourdomain.com mysql:/etc/postfix/mysql-domains.cf

6. vi /etc/postfix/mysql-users.cf

host = localhost

user = root

password =

dbname = postfix

table = mailbox

select_field = maildir

where_field = username

additional_conditions = and active = '1'

result_format = %sMaildir/
7. Test point 6

[root@www postfix]# postmap -q support@yourdomain.com mysql:/etc/postfix/mysql-users.cf


[root@www postfix]#
8. start postfix

[root@www postfix]# postfix reload

[root@www postfix]# service postfix restart

Shutting down postfix: [FAILED]

Starting postfix: [ OK ]

[root@www postfix]#
9. Send mail
[root@www postfix]# telnet localhost smtp


Connected to localhost.localdomain (

Escape character is '^]'.

220 http://www.yourdomain.com ESMTP Postfix

ehlo host



250-SIZE 10240000





250 DSN

mail from: support@yourdomain.com

250 2.1.0 Ok

rcpt to: webmaster@yourdomain.com

250 2.1.5 Ok


354 End data with <CR><LF>.<CR><LF>

Dear Marie,

How are you? Alles goed?




250 2.0.0 Ok: queued as 4E20D5F88033


221 2.0.0 Bye

Connection closed by foreign host.

[root@www postfix]#
[root@www home]# tree


|-- shamun

`-- vmail

`-- webmaster@yourdomain.com

`-- Maildir

|-- cur

|-- new

| `-- 1269444409.Vfd00I13d0017M216619.www.yourdomain.com

`-- tmp

7 directories, 1 file

[root@www home]#
Dovecot Installation:
1. Install dovecot (dovecot-mysql not need in centos 5.4)

[root@www home]# yum install dovecot.x86_64


dovecot.x86_64 0:1.0.7-7.el5
2. Edit

[root@www home]# whereis dovecot

dovecot: /usr/sbin/dovecot /etc/dovecot.conf /usr/libexec/dovecot

[root@www home]# vi /etc/dovecot.conf

# Protocols we want to be serving: imap imaps pop3 pop3s

# If you only want to use dovecot-auth, you can set this to "none".

protocols = pop3 pop3s imap imaps


## Mailbox locations and namespaces


mail_location = maildir:~/Maildir/


## IMAP specific settings


protocol imap {

imap_client_workarounds = delay-newmail outlook-idle netscape-eoh



## POP3 specific settings


protocol pop3 {

pop3_uidl_format = %08Xu%08Xv

pop3_client_workarounds = outlook-no-nuls oe-ns-eoh



## Authentication processes


# For 64-bit users: Add the line login_process_size = 64 in the file /etc/dovecot.conf.

auth_username_format = %Lu

auth default {

passdb sql {

args = /etc/dovecot-mysql.conf


userdb static {

#args = uid=501 gid=501 home=/home/vmail/%d/%n


args = uid=501 gid=501 home=/home/vmail/%u

#/home/vmail/marie@shamun.be/Maildir/new i am using this way!



3. vi /etc/dovecot-mysql.conf

driver = mysql

connect = host=localhost dbname=postfix user=root password=

default_pass_scheme = PLAIN

password_query = SELECT password from mailbox where username = '%u'

4. Start dovecot

[root@www home]# service dovecot restart

Stopping Dovecot Imap: [FAILED]

Starting Dovecot Imap: [ OK ]
5. Test

[root@www home]# telnet localhost pop3


Connected to localhost.localdomain (

Escape character is '^]'.

+OK Dovecot ready.

user webmaster@example.com


pass xxxxxxxxxx

+OK Logged in.


+OK 1 messages:

1 520



+OK Logging out.

Connection closed by foreign host.

[root@www home]#

Categories: centOS, Fedora 12, MySQL, Unix/Linux Tags:
  1. Glidic Anthony
    April 20, 2010 at 7:25 pm

    Hi this is a great howto. I just ask if it’s possible to add quota on mailbox?
    And an other question if for the moment all my mailboxes (whatever the domain) as directly created on /home/vmail. It is possible to have a tree like:

    • shamuntoha
      April 20, 2010 at 8:18 pm

      yes->Postfix Installation->point->9. Send mail

      • Glidic Anthony
        April 26, 2010 at 3:36 pm

        Yes i see your tree but what i want to say is: you have many domains and on each domain you have many account so i want this account will be created on a subdirectory (domain) in the /home/vmail
        —–test (test@test.net)
        —–test2 (test2@test.net)
        —–test (test@test.org)
        —–test2 (test2@test.org)

  2. July 29, 2010 at 2:49 pm

    Hello Shamuntoha,Study, I was studying how the linux install mail server, please visit my blog.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: