Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

Virtual Users With Postfix, Dovecot, MySQL, RoundCube, iRedAdmin On Debian 6.0 (Squeeze)

This document describes how to install a Postfix and Dovecot mail server that is based on virtual users and domains, i.e. users and domains that are in a MySQL database. If you prefer to install such a mail server step by step, you can refer to the ISPmail tutorials at Also the Big Picture would help you to easily understand the mail server structure. I believe you at least need one day to have a working mail server that way. If you use the iRedMail script, you only need one minute to get the mail server up and running, and you will have more features (compared to the ISPmail tutorials).

What is iRedMail?

  • iRedMail is a shell script.
  • It lets you quickly deploy a full-featured mail solution in less than 2 minutes.
  • iRedMail supports both OpenLDAP and MySQL as backends for storing virtual domains and users.
  • iRedMail officially provides the iRedAdmin web panel for managing mail servers.
  • Most components used in iRedMail are provided by Linux distributions officially. It means that iRedMail users can get software update support for as long as the the distribution is supported.
  • It supports RedHat, CentOS, Debian, Ubuntu, OpenSuSE, FreeBSD on both i386 and x86_64 architectures.
  • It provides RoundCube 0.5.1 as a webmail program.

Useful links:

  • Why are users interested in iRedMail:
  • Discussion forum:
  • Project home page:
  • Project Demo:


1 Requirements

It is strongly recommended to use the Debian NetInstall version to install a minimal Debian system, and then deploy the mail service via the iRedMail solution. e.g.:

To install such a system you will need the following:

  • Debian Squeeze (Debian 6.0) ISO; download Debian CD/DVD images via HTTP/FTP
  • Internet connection.


2 Preliminary Note

In this tutorial we use:

  • Hostname:
  • IP address:
  • The first virtual domain:
  • iRedMail installs all packages from official apt repositories on Debian 6. On Debian 5, it installs from official apt repositories and the backports repository.


3 Setting The Hostname

In Debian, the hostname is set in these two files:

  • /etc/hosts: hostname <=> IP address mapping
  • /etc/hostname: hostname setting

Map this hostname to ‘’ (warning: list the FQDN hostname as the first item!).

Edit /etc/hosts:       localhost        mail

Edit /etc/hostname:


Let the hostname modification take effect at once:

# /etc/init.d/

Verify the FQDN hostname:

# hostname


#hostname -f


4 Install Necessary Packages

We need to have bzip2 installed for extracting iRedMail.

# apt-get install bzip2


5 Start iRedMail Installation

Switch to the root user, we must execute further commands as the root user without sudo.

$ sudo su –

Download the new version of iredmail and start the installation:

# wget
# tar jxvf iRedMail-0.7.0.tar.bz2
# cd iRedMail-0.7.0
# bash


  • It will download 3 source tarballs of iRedAdmin, RoundCube and iRedAPD.
  • It will install the package “dialog” first.

Welcome page:


Choose the directory that will be used to store users’ mailboxes.


iRedMail supports both OpenLDAP and MySQL as backends to store virtual domains and users. We choose MySQL.


Set the MySQL root password:


Add your first virtual domain, e.g.:


Set a password for the virtual domain admin:, you can log into iRedadmin and Awstats with this account.


Set a password for the first normal user for the first virtual domain:


Select optional components:


Select the default language for your webmail application:


The configuration is now finished, we can now start the installation:

Configuration completed.
***************************** WARNING ***********************************
*                                                                       *
* Please do remember to *MOVE* configuration file after installation    *
* completed successfully.                                               *
*                                                                       *
*   * /root/iRedMail-0.7.0-beta2/config
*                                                                       *
< INFO > Continue? [Y|n]

Finish the installation:

* iRedMail-0.7.0-beta3 installation and configuration complete.
< Question > Would you like to use firewall rules shipped within iRedMail now?
< Question > File: /etc/default/iptables, with SSHD port: 22. [Y|n]
< INFO > Copy firewall sample rules: /etc/default/iptables.
insserv: warning: script 'K01iredapd' missing LSB tags and overrides
insserv: warning: script 'iredapd' missing LSB tags and overrides
< Question > Restart firewall now (with SSHD port 22)? [y|N]
< Question > Would you like to start postfix now? [y|N]
*   # for i in rsyslog  apache2 postfix mysql postfix-policyd dovecot amavis clamav-daemon clamav-freshclam cron iptables; do /etc/init.d/${i} restart; done

Restart all the related services manually without reboot:

# for i in rsyslog apache2 postfix mysql postfix-policyd dovecot amavis clamav-daemon clamav-freshclam cron iptables; do /etc/init.d/${i} restart; done

6 Test The Mail System

6.1 Webmail RoundCube

By default, iRedMail only enables two RoundCube plugins: “password” and “managesieve”, so that you can change passwords, create filters, and set up vacation.

Log into the RoundCube, use the first user


The account has received two emails, read them carefully. The iRedMail tips include all the passwords and settings of your mail server, keep it secret.
Note: because is a root alias, it receives system emails.


Setting up a vacation autoresponder:


6.2 iRedAdmin

iRedAdmin Open Source Edition is a web-based iRedMail admin panel, it allows you to add, remove and edit domains, users and domain admin accounts. If you need more features, please consider purchasing the Pro edition iRedAdmin-Pro.

You can also manage all the features of iRedAdmin-Pro with phpMyAdmin.

Log into iRedAdmin:




Mail Domains:


Mail Admin:


The log:


Create new mail user:


Create new domain:


Create global admin:


Select language:


6.3 Awstats

Log into Awstats:


Check the statistics:


7 Important Things You Should Know After Installation

  • Read file ‘iRedMail-x.y.z/’ first, example it contains:
    • User password and related sensitive information.
    • Location of mail server related software configuration files and other important information.
  • Set Up DNS record for SPF
  • Set Up DNS record for DKIM
  • Enable signing disclaimer on outgoing mails

8 Access Webmail And Other Web-Based Programs

After the installation is complete, you can access web-based programs if you’ve chosen to install them:

Component URL Access via HTTP Access via HTTPS Comment
Roundcube http://your_server/mail/ (or /webmail, /roundcube) YES YES Recommand webmail
iRedAdmin https://your_server/iredadmin NO YES Both for LDAP and MySQL
phpMyAdmin https://your_server/phpmyadmin/ (or /mysql) NO YES
Awstats https://your_server/awstats/ NO YES

Note: Replace your_server with your server hostname or IP address.

iRedAdmin, phpMyAdmin and Awstats use https access by default.