Files
docs/Servers/Linux/iRedMail.md
2024-01-06 20:05:41 -07:00

3.1 KiB

Purpose: Self-Hosted Open-Source email server that can be setup in minutes, and is enterprise-grade if upgraded with an iRedAdmin-Pro license.

!!! note "Assumptions" It is assumed you are running at least Rocky Linux 9.3. While you can use CentOS Stream, Alma, Debian, Ubuntu, FreeBSD, and OpenBSD, the more enterprise-level sections of my homelab are built on Rocky Linux.

Deployment

The instructions below are specific to my homelab environment, but can be easily ported depending on your needs. You can follow along with the official documentation on Installation as well as DNS Record Configuration if you want more detailed explanations throughout the installation process.

Start by connecting to the server / VM via SSH, then issue the commands below:

# Elevate to Root User
sudo su

# Define some deployment variables.  
VERSION="1.6.8" # (1)
MAIL_DOMAIN="bunny-lab.io" # (2)
POSTMASTER_PASSWORD="SecurePassword101" # (3)

# Check for Updates in the Package Manager
yum update -y

# Install Extra Packages for Enterprise Linux
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

# Download the iRedMail binaries and extract them
cd /root
curl https://codeload.github.com/iredmail/iRedMail/tar.gz/refs/tags/$VERSION -o iRedMail-$VERSION.tar.gz
tar zxf iRedMail-$VERSION.tar.gz
  1. This is the version of iRedMail you are deploying.
  2. This is the domain suffix that appears after mailbox names. e.g. first.last@domain.com
  3. For the purposes of the installation, you cannot use symbols in your password here. Keep it to letters and numbers.

Create the unattend config file for silent deployment (Copy/Paste the one-liner into the SSH terminal). This will automatically generate random 32-character passwords for all of the internal databases. You will set the postmaster password and mail domain in the next step.

(echo "export STORAGE_BASE_DIR='/var/vmail'"; echo "export WEB_SERVER='NGINX'"; echo "export BACKEND_ORIG='PGSQL'"; echo "export BACKEND='PGSQL'"; for var in VMAIL_DB_BIND_PASSWD VMAIL_DB_ADMIN_PASSWD MLMMJADMIN_API_AUTH_TOKEN NETDATA_DB_PASSWD AMAVISD_DB_PASSWD IREDADMIN_DB_PASSWD RCM_DB_PASSWD SOGO_DB_PASSWD SOGO_SIEVE_MASTER_PASSWD IREDAPD_DB_PASSWD FAIL2BAN_DB_PASSWD; do echo "export $var='$(openssl rand -base64 48 | tr -d '+/=' | head -c 32)'"; done; echo "export PGSQL_ROOT_PASSWD='PLACEHOLDER'"; echo "export DOMAIN_ADMIN_PASSWD_PLAIN='PLACEHOLDER'"; echo "export FIRST_DOMAIN='$MAIL_DOMAIN'"; echo "export USE_IREDADMIN='YES'"; echo "export USE_SOGO='YES'"; echo "export USE_NETDATA='YES'"; echo "export USE_FAIL2BAN='YES'") > /root/iRedMail-$VERSION/config


Deploy iRedMail via the Install Script

cd /root/iRedMail-1.6.8 bash iRedMail.sh


!!! note
    Please substitute the `1.6.8` version number if a newer version of iRedMail is available.  You can check for the most recent version number on the [Official Download Page](https://www.iredmail.org/download.html).