Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

iRedMail 0.7.0: Open Source Mail Server With Postfix, Dovecot, Amavisd, ClamAV, SpamAssassin, RoundCube On Ubuntu 10.04


iRedMail is a shell script that lets you quickly deploy a Open Source Mail Server solution in less than 2 minutes.

  • It supports Red Hat(R) Enterprise Linux & CentOS 5.x, Debian 5.0.x, Ubuntu 8.04/9.04/9.10/10.04, FreeBSD 7.x/8.x, it supports both i386 and x86_64.
  • Most components used in iRedMail are provided by Linux distributions officially, it means iRedMail users can get software update support for as long as for the distribution itself.
  • It supports OpenLDAP and MySQL as backends to save the virtual domains and virtual users.
  • It offers a web-based admin panel.

iRedMail was initially published in 2007, and now iRedMail 0.6.1 also supports Ubuntu 10.04.

  • Main components used in this solution: http://code.google.com/p/iredmail/wiki/Main_Components
  • Discussion forum: http://www.iredmail.org/forum/
  • Project home page: http://code.google.com/p/iredmail/
  • Project DEMO: http://demo.iredmail.org/

 

1 Requirements

To install such a system you will need the following:

  • The Ubuntu 10.04 server CD, available here: http://releases.ubuntu.com/releases/10.04/ubuntu-10.04.1-server-i386.iso (i386) or http://releases.ubuntu.com/releases/10.04/ubuntu-10.04.1-server-amd64.iso (x86_64)
  • It is strongly recommended to install a minimal Ubuntu system, and then deploy the mail service via the iRedMail solution.
  • For 10.04 (Lucid, LTS), it is not needed to modify default /etc/apt/sources.list. iRedMail uses packages from the default stable version, both ‘main’ and ‘universe’ repositories .
  • iRedMail is designed to deploy on a FRESH server system, which means it doesn’t have mail related components installed, e.g. Apache, MySQL, OpenLDAP, Postfix, Dovecot, Amavisd, etc. Otherwise it may override your existing files/configurations althought it  will backup files before modify.

 

2 Preliminary Note

In this tutorial we use:

  • Hostname: mail.example.com
  • IP address: 192.168.1.10
  • LDAP suffix: dc=example,dc=com
  • The first virtual domain: example.com

 

3 Setting The Hostname

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

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

Map this hostname to 127.0.0.1. (Warning: List the FQDN hostname as the first item.)

cat /etc/hosts

127.0.0.1       localhost
192.168.1.10   mail.example.com      mail

cat /etc/hostname

mail

Verify the FQDN hostname:

# hostname –fqdn

mail.example.com

 

4 Start To Install iRedMail

Update your ubuntu to the latest version:

#apt-get update
#apt-get upgrade

Download the new version of iredmail:

# wget http://iredmail.googlecode.com/files/iRedMail-0.7.0.tar.bz2
# tar jxvf iRedMail-0.7.0.tar.bz2

 

Start the iRedMail installer:

# cd iRedMail-0.7.0
# bash iRedMail.sh

Welcome page:

iredmail_01

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

iredmail_02

iRedMail supports both OpenLDAP and MySQL as backends to store virtual domains and users. OpenLDAP is recommended.

iredmail_03

LDAP suffix, normally it’s your domain name, such as: dc=example,dc=com:

iredmail_04

Set password for LDAP server admin: cn=Manager,dc=example,dc=com

iredmail_05

Set the MySQL root password:

iredmail_06

Add your first virtual domain, e.g.:

iredmail_07

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

iredmail_08

Set password for the first normal user www@example.com for the first virtual domain:

iredmail_09

Select optional components:

iredmail_10

Select the default language for your webmail application:

iredmail_12

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

iredmail_14

Finish the installation:

*************************************************************************
* iRedMail-0.6.1 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.
< Question > Restart firewall now (with SSHD port 22)? [y|N]
< INFO > Skip restart firewall.
< INFO > Installing php Net_LDAP2 …
PHP Deprecated:  Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/imap.ini on line 1 in Unknown on line 0
PHP Deprecated:  Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
< Question > Would you like to start postfix now? [y|N]

********************************************************************
* Congratulations, mail server setup complete. Please refer to tip
* file for more information:
*
*   – /root/iRedMail-0.6.1/./iRedMail.tips
*
* And it’s sent to your mail account www@example.com.
*
* If you want to remove and re-install iRedMail, here are steps:
*   – Run script to remove main components installed by iRedMail:
*       # wget http://iredmail.googlecode.com/hg/extra/clear_iredmail.sh
*       # mv clear_iredmail.sh tools/ && cd tools/
*       # bash clear_iredmail.sh
*   – Remove iRedMail installation process status:
*       # rm -f /root/iRedMail-0.6.1/./.iRedMail.installation.status
*   – Install iRedMail like you did before.
*
* Please reboot your system to enable mail related services or start them
* manually without reboot:
*
*   # for i in rsyslog  apache2 postfix mysql slapd postfix-policyd dovecot amavis clamav-daemon clamav-freshclam
cron iredapd iptables; do /etc/init.d/${i} restart; done
*
********************************************************************

Restart all the related services:

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

Update freshclam, maybe you need to restart the machine to make this work.

# freshclam

ClamAV update process started at Sun Aug 22 17:47:00 2010
main.cvd is up to date (version: 52, sigs: 704727, f-level: 44, builder: sven)
daily.cvd is up to date (version: 11609, sigs: 113386, f-level: 53, builder: ccordes)
bytecode.cvd is up to date (version: 39, sigs: 9, f-level: 53, builder: edwin)

5 Test The Mail System

5.1 Webmail RoundCube

Since RoundCube 0.31, it starts to support plugins. By default, iRedMail enables the two plugins “password” and “managesieve”, so you can change the password and set up a vacation autoresponder. You can also enable the other plugins according to your needs.

Log into the RoundCube, use the first user www@example.com:

iredmail_28

The account has received two emails, read them carefully.
Note: because www@exmaple.com is a root alias, it receives system emails.

iredmail_29

Setting up a vacation autoresponder:

iredmail_30_1

5.2 iRedAdmin Open Source Edition

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, you can check the full-featured edition.

Log into iRedAdmin: postmaster@example.com

iredmail_30

Dashboard:

iredmail_31

Mail Domains:

iredmail_32

Mail Users:

iredmail_33

Mail Admin:

iredmail_34

Create new mail user:

iredmail_35

Select language:

iredmail_36

5.3 phpLDAPAdmin

Log into phpLDAPAdmin: cn=manager,dc=example,dc=com

iredmail_37

Manage the mail account:

iredmail_38

5.4 Awstats

Log into Awstats: postmaster@example.com

iredmail_39

Check the statistics:

iredmail_40

6 Important Things You Should Know After Installation

  • Read the file /root/iRedMail/iRedMail.tips first, it contains:
    • User password and related sensitive information.
    • Location of mail serve related software configuration files and other important information.
  • Setup DNS record for SPF
  • Setup DNS record for DKIM
  • iRedMail Admin Guide

 

7 FAQ

7.1 Why do I receive my email with a delay?

iRedMail provides greylisting features with Policyd (v1.8.x), Greylisting is effective because many mass e-mail tools utilized by spammers are not set up to handle temporary failures (or any failures for that matter) so the Spam is never received. This feature can reduce e-mail traffic up to 50%, but would cause the first time receive email delay. You can enable or disable the greylisting.

On Ubuntu, config file is /etc/postfix-policyd.conf:

#   1=on  0=off 
GREYLISTING=1

Restart Policyd and reload Postfix.

 

7.2 How to upgrade iRedMail to the newest version?

iRedMail was set up from packages, so you can use APT to update the packages. Here’s the official iRedMail Upgrade Tutorial.

 

7.3 How to enable disclaimers for outgoing mails?

Find below lines in /etc/amavis/conf.d/50-user .

# ------------ Disclaimer Setting ---------------
# Uncomment this line to enable singing disclaimer in outgoing mails.
#$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];

Uncomment the line and restart amavis/amavisd service, then you get it. Don’t forget to read @disclaimer_options_bysender_maps in /etc/amavisd.conf for disclaimer content settings.

 

7.4 How to batch create users?

You must modify the script create_mail_user_OpenLDAP.sh first, change ldap suffix, bind dn and bind password.

# cd /path/to/iRedMail-x.y.z/tools/
# sh create_mail_user_OpenLDAP.sh domain.ltd user01 user02 user03

 

7.5 Anti-Virus & Anti-Spam – how to turn them on or off?

iRedMail uses Amavisd-new as interface between MTA and MDA, it will invoke SpamAssassin for anti-spam and ClamAV for anti-virus. You can turn them on or off in /etc/amavisd.conf .

# @bypass_virus_checks_maps = (1);  # controls running of anti-virus code
# @bypass_spam_checks_maps  = (1);  # controls running of anti-spam code
# $bypass_decode_parts = 1;         # controls running of decoders&dearchivers

Default settings are both enabled, you can uncomment them to bypass (turn off) them. Value ‘1’ means disabled.

 

7.6 How to create your own SSL key?

If you want to create own SSL key, you can download:

# wget http://iredmail.googlecode.com/hg/iRedMail/tools/generate_ssl_keys.sh

Edit the related info in the script:

# SSL key.
export SSL_CERT_FILE="${ROOTDIR}/certs/iRedMail_CA.pem"
export SSL_KEY_FILE="${ROOTDIR}/private/iRedMail.key"
export TLS_COUNTRY='CN'
export TLS_STATE='GuangDong'
export TLS_CITY='ShenZhen'
export TLS_COMPANY="${HOSTNAME}"
export TLS_DEPARTMENT='IT'
export TLS_HOSTNAME="${HOSTNAME}"
export TLS_ADMIN="root@${HOSTNAME}"

Run the script:

# bash generate_ssl_keys.sh

SSL keys were generated:
– /root/certs/iRedMail_CA.pem
– /root/private/iRedMail.key

Back up the old ssl_key, and copy the new key to:

/etc/ssl/private/iRedMail.key
/etc/ssl/certs/iRedMail_CA.pem

Comments

comments