Setup mail server with Postfix, Dovecot, Roundcube

Prerequisites

  • CentOS 6: minimal installation

  • Postfix: SMTP

  • Dovecot: IMAP, POP3

  • Roundcube: web-based IMAP client

  • Postfix admin: to easily manage Postfix

To work properly, system needs to have selinux disabled.

# vi /etc/selinux/config

Setup mail server with Postfix, Dovecot, Roundcube

Install Postfix

From the console, install Postfix with yum command.

# yum install postfix

Setup mail server with Postfix, Dovecot, Roundcube


Edit configuration file /etc/postfix/main.cf and set the parameters as follow:
______________________________________________________________________

myhostname = hostname.domain.com 

mydomain = domain.com 

myorigin = $mydomain 

inet_interfaces = all 

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 

mynetworks = 192.168.1.0/24, 127.0.0.0/8 

home_mailbox = Maildir/

______________________________________________________________________

# vi /etc/postfix/main.cf

________________________________

myhostname = hostname.domain.com 

mydomain = domain.com 

myorigin = $mydomain

________________________________

Setup mail server with Postfix, Dovecot, Roundcube

inet_interfaces = all

Setup mail server with Postfix, Dovecot, Roundcube

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

Setup mail server with Postfix, Dovecot, Roundcube

mynetworks = 192.168.1.0/24, 127.0.0.0/8

Setup mail server with Postfix, Dovecot, Roundcube

home_mailbox = Maildir/

Setup mail server with Postfix, Dovecot, Roundcube

Once all the parameters have been set, set application to start during system boot and start the service.

# chkconfig postfix on
# service postfix start

Setup mail server with Postfix, Dovecot, Roundcube

Testing Postfix

To check if everything works as expected, type from console the following commands to send an email:

# telnet localhost smtp

Setup mail server with Postfix, Dovecot, Roundcube


To check if the email has been received, have a look at the /home/username/Maildir/newdirectory.

# cd /home/username/Maildir/new/
# ll
# cat xxxxx.xxxxx.server.domain.com

Setup mail server with Postfix, Dovecot, Roundcube


The email was received by the system then the mail server is working properly.


Install Dovecot

While Postfix acts as Mail Transfer Agent (MTA) only, in order to retrieve emails using modern tools we need to enable IMAP/POP3 protocols. Dovecot is an application that acts as a secureIMAP and POP3 server.

Use the yum command to install Dovecot.

# yum install dovecot

Setup mail server with Postfix, Dovecot, Roundcube

Edit the configuration file /etc/dovecot/dovecot.conf to enable the needed protocols.

# vi /etc/dovecot/dovecot.conf

Setup mail server with Postfix, Dovecot, Roundcube

Then we need to specify the mail location by editing the file /etc/dovecot/conf.d/10-mail.conf.

# vi /etc/dovecot/conf.d/10-mail.conf

Setup mail server with Postfix, Dovecot, Roundcube


Edit the file /etc/dovecot/conf.d/10-auth.conf and set the following parameters:

# vi /etc/dovecot/conf.d/10-auth.conf

Setup mail server with Postfix, Dovecot, Roundcube

Setup mail server with Postfix, Dovecot, Roundcube



Last file to edit /etc/dovecot/conf.d/10-master.conf.

# vi /etc/dovecot/conf.d/10-master.conf

Setup mail server with Postfix, Dovecot, Roundcube


Set Dovecot to start at system boot and start the service.

# chkconfig dovecot on
# service dovecot start

Setup mail server with Postfix, Dovecot, Roundcube

Testing Dovecot

To check if Dovecot is working, we test the program through the POP3 protocol.

# telnet localhost pop3

Setup mail server with Postfix, Dovecot, Roundcube

Install Roundcube

Roundcube is a browser-based IMAP client with an application-like user interface.

To configure the application, firstly we need to install MySQL server and Apache in the system.

# yum install mysql-server mysql-devel httpd

Setup mail server with Postfix, Dovecot, Roundcube

Enable both MySQL and Apache to start at system boot and enable services.

# chkconfig mysqld on
# service mysqld start

# chkconfig httpd on
# service httpd start

 

Install EPEL repository

To install Roundcube with yum command, we need to install the EPEL repository in the system.

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

Setup mail server with Postfix, Dovecot, Roundcube

Once EPEL repo has been installed, use yum to install Roundcube.

# yum install roundcubemail

Setup mail server with Postfix, Dovecot, Roundcube

Configure MySQL

To define the database used by the application, we need to access MySQL configuration.

# mysql -u root -p

Setup mail server with Postfix, Dovecot, Roundcube

Edit configuration file /etc/roundcubemail/db.inc.php to set the parameters to access the database.

# vi /etc/roundcubemail/db.inc.php

Setup mail server with Postfix, Dovecot, Roundcube

Edit the file /etc/roundcubemail/main.inc.php to set the hostname chosen to perform the login.

# vi /etc/roundcubemail/main.inc.php

Setup mail server with Postfix, Dovecot, Roundcube

To make the system accessible outside the server, edit the file/etc/httpd/conf.d/roundcubemail.conf and set the correct parameter.

# vi /etc/httpd/conf.d/roundcubemail.conf

Setup mail server with Postfix, Dovecot, Roundcube

Edit the /etc/php.ini file and set the time zone.

Setup mail server with Postfix, Dovecot, Roundcube

Because the log could report errors related to encryption, set the correct encryption parameter.

# vi /etc/php.d/mcrypt.ini

Setup mail server with Postfix, Dovecot, Roundcube

Restart Apache.

# service httpd restart

 

Testing Roundcube

Access Roundcube typing from your browser the address:

http://IP_address/roundcubemail

Enter your credential then click Login.

Setup mail server with Postfix, Dovecot, Roundcube

The main screen appears showing the email received when Postfix was previously tested.

Setup mail server with Postfix, Dovecot, Roundcube

Install Postfix Admin

To make Postfix administration easier, the Postfix admin is a web-based tool used to manage mailboxes, virtual domains and aliases.

If not already present in the system, install the PHP component needed by the application.

# yum install php-imap

Access MySQL and create the database used by Postfix Admin.

# mysql -u root -p

Setup mail server with Postfix, Dovecot, Roundcube

Using the wget command, download the latest release of the application.

# wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.3.6/postfixadmin-2.3.6.tar.gz

Setup mail server with Postfix, Dovecot, Roundcube

Extract the content and move the directory to /var/www/html folder.

# tar -vxzf postfixadmin-2.3.6.tar.gz
# mv postfixadmin-2.3.6 /var/www/html/postfixadmin

Setup mail server with Postfix, Dovecot, Roundcube

Edit the configuration file /var/www/html/postfixadmin/config.inc.php to enable the applicationand set the password.

# vi /var/www/html/postfixadmin/config.inc.php

Setup mail server with Postfix, Dovecot, Roundcube

Set the correct parameters to access the database previously created.

Setup mail server with Postfix, Dovecot, Roundcube

Add the following line to allow the creation of the administration password.

Setup mail server with Postfix, Dovecot, Roundcube

Restart Apache.

# service httpd restart

To execute the Postfix Admin Setup Checker, type in your browser the address:

http://IP_address/postfixadmin/setup.php

Setup mail server with Postfix, Dovecot, Roundcube

Change the setup password.

Setup mail server with Postfix, Dovecot, Roundcube

Create the Superadmin account by filling the fields at the bottom of the screen. Click Add Admin.

Setup mail server with Postfix, Dovecot, Roundcube

The Superadmin account is then created.

Setup mail server with Postfix, Dovecot, Roundcube

To access the Administration interface, type in your browser the address:

http://IP_address/postfixadmin

Setup mail server with Postfix, Dovecot, Roundcube

The Postfix Admin main screen.

Setup mail server with Postfix, Dovecot, Roundcube

Sending emails through a relay

If the corporate network has an antispam system to check inbound and outbound emails, Postfix needs to be configured in order to relay the emails to the antispam.

To allow the correct emails flow, set the relayhost field with the address of the antispam system.

# vi /etc/postfix/main.cf

Setup mail server with Postfix, Dovecot, Roundcube

The mail server is now up and running with the basic functions to properly manage emailmessages.



你可能感兴趣的:(postfix,webmail,roundcube)