Académique Documents
Professionnel Documents
Culture Documents
Roundcube
Paolo Valsecchi 19/06/2013 21 Comments
A working mail server can be configured using Postfix (MTA) with the addition of some
components like Dovecot (IMAP) and Roundcube (webmail).
Combining these applications we obtain an email system with SMTP, IMAP, POP3 protocols that
can be used in a corporate environment where the budget is pretty limited. This solution is based on
Open Source software where no licenses need to be purchased for its use.
Prerequisites
• CentOS 6: minimal installation
• Postfix: SMTP
• Dovecot: IMAP, POP3
• Roundcube: web-based IMAP client
• Postfix admin: to easily manage Postfix
myhostname = hostname.domain.com
1 mydomain = domain.com
2
myorigin = $mydomain
inet_interfaces = all
3
mydestination = $myhostname,
4
localhost.$mydomain, localhost,
5 $mydomain
6 mynetworks = 192.168.1.0/24,
7 127.0.0.0/8
home_mailbox = Maildir/
# vi /etc/postfix/main.cf
inet_interfaces = all
1 inet_interfaces = all
1 home_mailbox = Maildir/
Once all the parameters have been set, set application to start during system boot and start the
service.
# chkconfig postfix on
# service postfix start
Testing Postfix
To check if everything works as expected, type from console the following commands to send an
email:
# telnet localhost smtp
Trying ::1... Connected to localhost. Escape character is '^]'. 220 server.domain.com ESMTP Postfix ehlo localhost 250-
server.domain.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-
8BITMIME 250 DSN mail from: username@domain.com 250 2.1.0 Ok rcpt to: username@domain.com 250 2.1.5 Ok data 354 End
data with <CR><LF>.<CR><LF> test . 250 2.0.0 Ok: queued as 2C55A94 quit 221 2.0.0 Bye Connection closed by foreign host.
Trying ::1...
Connected to
localhost.
Escape
character is
'^]'.
220
server.domai
n.com
ESMTP
Postfix
ehlo
localhost
250-
1
server.domai
2
n.com
3 250-
4 PIPELININ
5 G
6 250-SIZE
7 10240000
8 250-VRFY
9 250-ETRN
10
250-
11
ENHANCE
DSTATUSC
12
ODES
13
250-
14 8BITMIME
15 250 DSN
16 mail from:
17 username@d
18 omain.com
19 250 2.1.0 Ok
20 rcpt to:
21 username@d
22
omain.com
250 2.1.5 Ok
23
data
24
354 End data
25
with
<CR><LF>.
<CR><LF>
test
.
250 2.0.0
Ok: queued
as 2C55A94
quit
221 2.0.0
Bye
Connection
closed by
To check if the email has been received, have a look at the /home/username/Maildir/new directory.
# cd /home/username/Maildir/new/
# ll
# cat xxxxx.xxxxx.server.domain.com
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 secure
IMAP and POP3 server.
Use the yum command to install Dovecot.
# yum install dovecot
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
mail_location = maildir:~/Maildir
1 mail_location = maildir:~/Maildir
disable_plaintext_auth = no
1 disable_plaintext_auth = no
auth_mechanisms = plain login
1 unix_listener auth-userdb {
2 #mode = 0600
3 user = postfix
4 group = postfix
5 }
Trying ::1... Connected to localhost. Escape character is '^]'. +OK Dovecot ready. user admin +OK pass password +OK Logged in.
list +OK 1 messages: 1 477 . retr 1 +OK 477 octets Return-Path: <username@domain.com> X-Original-To: username@domain.com
Delivered-To: username@domain.com Received: from localhost (localhost [IPv6:::1]) by server.domain.com (Postfix) with ESMTP
id 2C55A94 for username@domain.com; Wed, 12 Jun 2013 12:22:00 +0200 (CEST) Message-Id:
<20130207113547.117113FF18@server.domain.com> Date: Wed, 12 Jun 2013 12:22:00 +0200 (CEST) From:
username@domain.com To: undisclosed-recipients:; test postfix . quit +OK Logging out. Connection closed by foreign host.
Trying ::1...
Connected to
localhost.
Escape
character is
'^]'.
+OK
Dovecot
ready.
user admin
+OK
pass
password
+OK Logged
in.
list
+OK 1
messages:
1 477
.
retr 1
+OK 477
octets
Return-Path:
1 <username@
2 domain.com
3 >
4 X-Original-
5 To:
6 username@d
7
omain.com
Delivered-
8
To:
9
username@d
10
omain.com
11 Received:
12 from
13 localhost
14 (localhost
15 [IPv6:::1])
16 by
17 server.domai
18
n.com
(Postfix)
19
with ESMTP
20
id 2C55A94
21
for
22 username@d
23 omain.com;
24 Wed, 12 Jun
25 2013
26 12:22:00
27 +0200
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
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
Once EPEL repo has been installed, use yum to install Roundcube.
# yum install roundcubemail
Configure MySQL
To define the database used by the application, we need to access MySQL configuration.
# mysql -u root -p
mysql> create database roundcube; mysql> create user roundcube; mysql> GRANT ALL PRIVILEGES ON roundcube.*
TO roundcube@localhost IDENTIFIED BY 'password'; mysql> flush privileges; mysql> use roundcube; mysql> source
/usr/share/doc/roundcubemail-0.8.6/SQL/mysql.initial.sql mysql> quit
Edit configuration file /etc/roundcubemail/db.inc.php to set the parameters to access the database.
# vi /etc/roundcubemail/db.inc.php
$rcmail_config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcube';
1 $rcmail_config['db_dsnw'] = 'mysql://roundcube:password@localhost/roundcube';
Edit the file /etc/roundcubemail/main.inc.php to set the hostname chosen to perform the login.
# vi /etc/roundcubemail/main.inc.php
$rcmail_config['default_host'] = 'localhost';
1 $rcmail_config['default_host'] = 'localhost';
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
Because the log could report errors related to encryption, set the correct encryption parameter.
# vi /etc/php.d/mcrypt.ini
extension=mcrypt.so
1 extension=mcrypt.so
Restart Apache.
# service httpd restart
Testing Roundcube
Access Roundcube typing from your browser the address:
http://IP_address/roundcubemail
mysql> create database postfixadmin; mysql> grant all privileges on postfixadmin.* to postfixadmin@'localhost' identified by
'password'; mysql> flush privileges; mysql> quit
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
$CONF['configured'] = true;
1
$CONF['setup_password'] =
2
'password';
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] =
1 'localhost';
2 $CONF['database_user'] =
3 'postfixadmin';
4 $CONF['database_password'] =
5 'password';
$CONF['database_name'] =
'postfixadmin';
Add the following line to allow the creation of the administration password.
$CONF['setup_password'] = '8abd38580e77ebf7010eb60b95eb4fad:0bd829114d9efc4bc35c7e42cf7d3507dad8b837';
$CONF['setup_password'] =
1
'8abd38580e77ebf7010eb60b95eb4fad:0bd829114d9efc4bc35c7e42cf7d3507dad8b837';
Restart Apache.
# service httpd restart
To execute the Postfix Admin Setup Checker, type in your browser the address:
http://IP_address/postfixadmin/setup.php
Change the setup password.
Create the Superadmin account by filling the fields at the bottom of the screen. Click Add Admin.
relayhost= lx-antispam02.nolabnoparty.local
1 relayhost= lx-antispam02.nolabnoparty.local
The mail server is now up and running with the basic functions to properly manage email
messages.