Dovecot /postfix with Roundcube WebUI

Following guide was tested on CentOS 6.

Install epel repository:

sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Remove sendmail and install dovecot:

yum remove sendmail
yum install postfix dovecot
chkconfig dovecot on
chkconfig postfix on
service dovecot start
service postfix start

Install php if not yet installed:

yum install php

Install php extentions:

yum install php-xml php-pdo php-mbstring php-mcrypt php-intl php-mysql

Add to your php.ini:

You can locate your working php.ini with the command:

php -i | grep 'Configuration File'

Restart Apache

service httpd restart

Install some database server. In this guide we use MySQL.

yum install mysql-server
chkconfig mysqld on
service mysqld start

Set mysql root password:

mysqladmin -u root password <password>

Enter to mysql:

mysql -p

Create user for Rouncube:

CREATE USER 'roundcube'@'localhost' IDENTIFIED BY 'password';

Create database:

CREATE DATABASE roundcubemail;

Grant privileges:

GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'password';

Download roundcube and extract it in web accessible directoty:

cd /var/www/html
tar xvf roundcubemail-1.0.1.tar.gz

For newest version refer to:

Now you can give some shorter name to it, for example - webmail:

mv roundcubemail-1.0.1 webmail
cd webmail
chmod 777 -R temp
chmod 777 -R logs

Go to web installer using url: http://YourDomainOrIP/webmail/installer

Press "NEXT" at the bottom of the page

Find "Database setup" section and set password for database that you've created in previous steps. You may also configure other options in this step.

Press "CREATE CONFIG" at the bottom of the page.

Two files will be generated and you should place them to your roundcube folder. In our case it is /var/www/html/webmail/config

cd /var/www/html/webmail/config
nano      #Copy content of the generated file from web page
nano        #Copy content of the generated file from web page


Perform test and finish installation.

Also you can note that the webmail UI do not show the time. You need to define your timezone in php.ini. For example:

date.timezone = Europe/Amsterdam

dovecot config

Basic management is available in webmin: Servers -> Dovecot IMAP/POP3 Server

for example we will done some basic config using CLI Edit dovecot config, /etc/dovecot/dovecot.conf

protocols = imap
mail_location =  maildir:~/Maildir

check auth parameters in configfile etc/dovecot/conf.d/10-auth.conf

auth_mechanisms = plain login

set maillocation in /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir

Add/uncomment in /etc/dovecot/conf.d/10-master.conf

unix_listener /var/spool/postfix/private/auth {
   mode = 0666
 user = postfix

List mailboxex

doveadm mailbox list

Create mailbox (if you set satndard linux auth this will not work for you)

 doveadm mailbox create -u test test

Create mailbox (if Data source for users, homes and IDs set to Standard Unix user database)

useradd test
mkdir /home/test/Maildir
chown test:test /home/test/Maildir
chmod -R 700 /home/test/Maildir

set password for newly created user:

passwd test 

Now you can login to roundcube WebUI using created user "test". Use "" or "localhost" as Server

Set dovecot autostart

chkconfig --level 345 dovecot on


test imap/ check mails from console You can install mutt

yum install mutt

After use commands like:

mutt -f imap://
mutt -f imap://ndi@localhost

After login you will get to the CLI UI and be able to see mailbox and send mails

Here is an example of working /etc/postfix/

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = localhost
mydomain =
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
debug_peer_level = 2
debugger_command =
         ddd $daemon_directory/$process_name $process_id & sleep 5 

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

You can map aliases with the following command:

postmap /path/to/file

Enable postfix to use an external mail clients

Add following lines to /etc/postfix/ for enabling sasl authentication:

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =

Add the following to /etc/dovecot/conf.d/10-auth.conf:

auth_mechanisms = plain login


Mail client settings:

Account type: IMAP
Incoming mail server:
port 993, SSL
Outgoing mail server (SMTP):
Auth required
port 25, unencrypted



    • If the emails do not appear in user mailbox but there no errors in the mailserver logfiles you can try to the next fix.

Please note that for testing this case you need to send email to yourself .

postconf -e 'home_mailbox = Maildir/'
export MAIL=/home/test/Maildir
service postfix restart


    • If you able to send emails but you can receive the emails only from yourself or/and from other your email server users you should check the Postfix IP address bind configuration.
netstat -tulpn

if you see the next line as one of the output

tcp        0      0      *                   LISTEN      25367/master  

it means that postfix can receive emails only from localhost. Change the allowed networks:

Edit/Add the next line in postfix config /etc/postfix/ to:

inet_interfaces = localhost,

Where is your main server IP. restart postfix after


replace "test" with actual username.

ADD: Using Virtual mailboxes:

Create the user vmail. Note the user GUID. In our example the GUID wqill be 500. Add/edit the next lines in /etc/postfix/

virtual_mailbox_domains =,,
virtual_mailbox_maps = hash:/etc/postfix/vmailbox        #this is txt file with emails and path to email folders
virtual_alias_maps = hash:/etc/postfix/virtual_aliases   #txy file with aliases
virtual_mailbox_base = /home/vmail                       #the vmail folder. you should chown it to vmail:vmail.
virtual_mailbox_limit_override = yes
virtual_maildir_extended = yes
virtual_overquota_bounce = yes
#virtual_mailbox_limit_maps = hash:/etc/postfix/vmailbox_limit  #txt file with limits
virtual_create_maildirsize = yes
virtual_trash_count = yes
virtual_trash_name = ".Trash"
virtual_mailbox_limit_inbox = no
virtual_minimum_uid = 500         #vmail user GUID. take a look on it in /etc/passwd for example.
virtual_uid_maps = static:500
virtual_gid_maps = static:500

Edit the mail location in /etc/dovecot.dovecot.conf :

mail_location = maildir:/home/vmail/%d/%n

Create the directory for user under /home/vmail/<domain>. For example: mkdir /home/vmail/ mkdir /home/vmail/ Mkae sure that correct permissions are set for vmail:vmail (*use chown)

Add user in /etc/postfix/vmailbox . For example:
#mail                  #path from vmail, not full.

Create aliases if need in /etc/postfix/virtual_aliases:

Use postmap to apply settings from vmailbox and virtual_aliases:

postmap /etc/postfix/vmailbox
postmap /etc/postfix/virtual_aliases

Generate CRAM-MD5 password hash for the user using doveadm command:

doveadm pw
Enter new password: password
Retype new password: password

Copy the result line . you will need to put it into the next step Open for edit the /etc/dovecot/users. Add/edit the user:{CRAM-MD5}26b633ec8bf9dd526293c5897400bddeef9299fad:500:500:/home/vmail/

That's all. For sure you can restart postfix and dovecot services.


  • Postfix delete mail queue

Remove all mail from the queue:

postsuper -d ALL

Remove all mails in the deferred queue:

postsuper -d ALL deferred

Was this answer helpful?

 Print this Article

Also Read


Installing mysql: yum install mysql-server Enter to mysql: mysql -u user -p password...


Diagnostic To display how many http connections are open at the moment, enter: netstat |...


How to install squid with tor [NOTE: According to AUP/TOS you can use private proxy...

Oracle 11g EX on Centos 6 x64 vps

We describe how to install Oracle 11g Express on Centos 6 x86_64 Openvz VPS. First of all you...

Web server

In this guide we will create our own web server on Centos 6.  We will use Apache...