Qmail is Founded in June of 2003. Put together to provide a free and open resource for anyone needing help with the installation and configuration. It is an incredibly fast, stable and secure mail solution suitable for almost any environment. Qmailrocks continues to grow and improve because of the generous contributions from devoted qmail fans across the world.

Step-1 (Download the Software and extract qmail pkgs)
# wget http://www.qmailrocks.org/downloads/qmailrocks.tar.gz
# mkdir /downloads
# cd /downloads
# tar zxvf qmailrocks.tar.gz
Step-2 (Installing Qmail Itself)
# /downloads/qmailrocks/scripts/install/qmr_install_linux-s1.script
# /downloads/qmailrocks/scripts/util/qmail_big_patches.script

Now we build Qmail…

# cd /usr/src/qmail/qmail-1.03
# make man && make setup check
# ./config-fast your_fqdn_hostname (ex: ./config-fast mail.galaxy.com)
# make cert
Country Name (2 letter code) [GB]:IN
State or Province Name (full name) [Berkshire]: MH
Locality Name (eg, city) [Newbury]: India
Organization Name (eg, company) [My Company Ltd]: MCH
Organizational Unit Name (eg, section) []: Computer Cell
Common Name (eg, your name or your server's hostname)
[]:mail.techbrown.com
Email Address []:postmaster@techbrown.com
Step-3 (EZmlm)
# cd /downloads/qmailrocks/
# tar zxvf ezmlm-0.53-idx-0.41.tar.gz
# cd ezmlm-0.53-idx-0.41
# make && make setup
Step-4 (Autoresponder)
# cd /downloads/qmailrocks
# tar zxvf autorespond-2.0.5.tar.gz
# cd autorespond-2.0.5
# make && make install
Step-5 (Vpopmail)
# cd /downloads/qmailrocks
# tar zxvf vpopmail-5.4.5.tar.gz
# cd vpopmail-5.4.5
# ./configure --enable-logging=p
# make && make install-strip
Step-6 (Vqadmin)
# cd /downloads/qmailrocks
# tar zxvf vqadmin-2.3.6.tar.gz
# cd vqadmin-2.3.6
# ./configure --enable-cgibindir=/var/www/cgi-bin --enablehtmldir=/var/www/html/
# make && make install-strip

Now you will need to add the following to your server’s Apache configuration file (usually httpd.conf)

<Directory "/var/www/cgi-bin/vqadmin">
deny from all
Options ExecCGI
AllowOverride AuthConfig
Order deny,allow
</Directory>

In addition, within the Apache master config file you will want to set the “AllowOveride” option to “All”.Example: AllowOveride All

# cd /var/www/cgi-bin/vqadmin
# vi .htaccess
AuthType Basic
AuthUserFile /usr/local/apache/conf/vqadmin.passwd
AuthName vQadmin
require valid-user
satisfy any
# chown apache .htaccess
# htpasswd -bc /usr/local/apache/conf/vqadmin.passwd admin admin
# chmod 644 /usr/local/apache/conf/vqadmin.passwd
# apachectl stop
# apachectl start
# http://mail.galaxy.com/cgi-bin/vqadmin/vqadmin.cgi
Step-7 (Maildrop)
# cd /downloads/qmailrocks
# tar zxvf maildrop-1.6.3.tar.gz
# cd maildrop-1.6.3
# ./configure --prefix=/usr/local --exec-prefix=/usr/local --enablemaildrop-uid=root --enable-maildrop-gid=vchkpw --enablemaildirquota
# make && make install-strip && make install-man
Step-8 (Qmailadmin)
# cd /downloads/qmailrocks
# tar zxvf qmailadmin-1.2.1.tar.gz
# cd qmailadmin-1.2.1
# ./configure --enable-cgibindir=/var/www/cgi-bin --enablehtmldir=/var/www/html/
# make && make install-strip
Step-9 (Finalizing Qmail)
# /downloads/qmailrocks/scripts/finalize/linux/finalize_linux.script

Find “mail.example.com” and change it to your server’s hostname. For example: mail.galaxy.com.

# vi /var/qmail/supervise/qmail-pop3d/run
# vi /var/qmail/supervise/qmail-smtpd/run

Next, we’ll kill any running qmail processes so that we can implement some final configurations.

# qmailctl stop

Setup Selective relaying Localhost

# echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
# qmailctl cdb
# echo postmaster@techbrown.com > /var/qmail/alias/.qmail-root
# echo postmaster@techbrown.com> /var/qmail/alias/.qmail-postmaster
# echo postmaster@techbrown.com> /var/qmail/alias/.qmail-mailerdaemon
# ln -s /var/qmail/alias/.qmail-root /var/qmail/alias/.qmailanonymous
# chmod 644 /var/qmail/alias/.qmail*

Removing Sendmail

# service sendmail restart
# rpm -qa | grep sendmail
# rpm -e --nodeps sendmail-x.x.x.x
# rpm -e --nodeps sendmail-doc-x.x.x.x
# rpm -e --nodeps sendmail-devel-x.x.x.x
# rpm -e --nodeps sendmail-cf-x.x.x.x
# /etc/rc.d/init.d/sendmail stop (to stop Sendmail)
# mv /usr/lib/sendmail /usr/lib/sendmail.old
# mv /usr/sbin/sendmail /usr/sbin/sendmail.old
# chmod 0 /usr/lib/sendmail.old /usr/sbin/sendmail.old

Delete Postfix

# rpm -qa | grep postfix
# postfix-x.x-x
# /etc/rc.d/init.d/postfix stop
# rpm -e nodeps postfix-x.x-x
# ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
# ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
Step-10 (Starting qmail)
# /downloads/qmailrocks/scripts/util/qmr_inst_check
# qmailctl stop
# qmailctl start
# qmailctl stat
# telnet localhost 110
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
+OK <16658.1054485137@yourserver.com>
user postmaster@techbrown.com (enter your username here remember to use the full e-mail address)
+OK
pass galaxy
+OK
quit
+OK
Connection closed by foreign host.
Step-11 (Installing Courier-imap/imaps with Courierpassd)
# cd /downloads/qmailrocks
# tar jxvf courier-authlib-0.55.tar.bz2
# cd courier-authlib-0.55
# ./configure --prefix=/usr/local --exec-prefix=/usr/local --withauthvchkpw--without-authldap --without-authmysql --disable-rootcheck--with-ssl --with-authchangepwdir=/usr/local/libexec/authlib --with-redhat
# make && make check
# make install-strip && make install-configure
# vi /etc/rc.local

Add the following line:

# /usr/local/sbin/authdaemond start

Now let’s install courier-imap/imaps…

# cd /downloads/qmailrocks/
# tar jxvf courier-imap-4.0.2.tar.bz2
# chown -R bsmith:wheel courier-imap-4.0.2
# cd /downloads/qmailrocks/courier-imap-4.0.2
# subsmith
# ./configure --prefix=/usr/local --exec-prefix=/usr/local --withauthvchkpw--without-authldap --without-authmysql --disable-rootcheck--with-ssl --with-authchangepwdir=/usr/local/libexec/authlib --with-redhat
# make && make check

We will exit out of our NON-ROOT USER and go back to being root.

# Exit
# make install-strip && make install-configure
# /usr/local/sbin/mkimapdcert
# vi /usr/local/etc/imapd.cnf
# vi /usr/local/etc/imapd
# vi /usr/local/etc/imapd-ssl
# vi /usr/local/etc/authlib/authdaemonrc authmodulelist="authvchkpw“
# cp /usr/local/libexec/imapd.rc /etc/rc.d/init.d/imap
# cp /usr/local/libexec/imapd-ssl.rc /etc/rc.d/init.d/imaps

Let’s start up Authdaemond, IMAP and IMAPS. To be safe we’ll stop each service before starting it.

# /usr/local/sbin/authdaemond stop
# /usr/local/sbin/authdaemond start
# /etc/rc.d/init.d/imap stop
# /etc/rc.d/init.d/imaps stop
# /etc/rc.d/init.d/imap start
# /etc/rc.d/init.d/imaps start
# telnet localhost 143
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE STARTTLS] Courier-IMAP ready. Copyright 1998-2003 Double Precision, Inc. See COPYING for distribution information.
a login postmaster@techbrown.com techbrown
a OK LOGIN Ok. (successful login!)
a logout (logs you out)
* BYE Courier-IMAP server shutting down
a OK LOGOUT completed
Connection closed by foreign host.

Note: Courierpassd will require that port 106 be open to at least local traffic (traffic from 127.0.0.1)

# cd /downloads/qmailrocks
# tar zxvf courierpassd-1.1.0-RC1.tar.gz
# cd courierpassd-1.1.0-RC1
# ./configure
# make && make install
# cd /etc/xinetd.d

Here we create the xinetd script for courierpassd.

# vi courierpassd
service courierpassd
 {
 port = 106
 socket_type = stream
 protocol = tcp
 user = root
 server = /usr/local/sbin/courierpassd
 server_args = -s imap
 wait = no
 only_from = 127.0.0.1
 instances = 4
 disable = no
 }
# vi /etc/services
# /etc/rc.d/init.d/xinetd restart
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
200 courierpassd v0.30 hello, who are you?
user postmaster@galaxy.org
200 Your password please.
pass galaxy
200 Your new password please.
newpass galaxy
200 Password changed, thank-you.
quit
200 Bye.
Connection closed by foreign host.
# telnet localhost 106
Step-12 (Installing Squirrelmail)
# cd /downloads/qmailrocks
# tar xvzf squirrelmail-1.4.8.tar.gz

Now rename the untarred folder to something more friendly.

# mv squirrelmail-1.4.8 webmail

And now let’s configure Squirrelmail.

# mkdir /var/sqattachements
# chown -R apache:apache /var/sqattachements
# cdwebmail
# chown -R apache:apache data
# cd config
# ./conf.pl

General Settings

1. Domain : 1.2.3.4 (Enter the IP of your server here. Don't be an idiot and actually use 1.2.3.4)
2. Invert Time : false
3. Sendmail or SMTP : SMTP

IMAP Settings

4. IMAP Server : localhost
5. IMAP Port : 143
6. Authentication type : login
7. Secure IMAP (TLS) : false
8. Server software : other
9. Delimiter : detect

SMTP Settings

4. SMTP Server : localhost
5. SMTP Port : 25
6. POP before SMTP : false
7. SMTP Authentication : login
8. Secure SMTP (TLS) : false

I edit the httpd.conf Apache configuration file and add the following block:

<VirtualHost 172.25.25.4:80>
ServerName mail.techbrown.com
ServerAlias mail.*
ServerAdmin postmaster@techbrown.com
DocumentRoot /var/www/webmail
</VirtualHost>
http://mail.techbrown.com

We’ll sign in with the postmaster account under the domain you should have created earlier using Vqadmin.

Username: postmaster@techbrown.com
Password: techbrown
/etc/rc.d/init.d/imap start
/etc/rc.d/init.d/imaps start
# qmailctl restart
# qmailstat

Congratulations now you have configured the Linux Mail Server Qmail on CentOS and RHEL.