iRedMail ist eine Open-Source-Lösung für vollständige Mailserver. Sie integriert Postfix, Dovecot, Spam-Filter und Webmail in einem einfach installierbaren Paket.

Warum iRedMail?

Komponenten

- Postfix (SMTP)
- Dovecot (IMAP/POP3)
- SpamAssassin (Spam-Filter)
- ClamAV (Antivirus)
- Roundcube (Webmail)
- SOGo (Groupware, optional)
- Fail2ban (Sicherheit)
- iRedAdmin (Verwaltung)

Vorteile

- Alles-in-einem-Lösung
- Einfache Installation
- Web-Administration
- Spam/Virus-Schutz integriert
- Kostenlos (Open Source)

Voraussetzungen

Systemanforderungen

- Frische Linux-Installation (Ubuntu 22.04 empfohlen)
- 4 GB RAM (minimum 2 GB)
- 20 GB Festplatte
- Statische IP-Adresse
- Gültiger FQDN (mail.example.com)

DNS-Einträge vorbereiten

# A-Record
mail.example.com.       IN  A       123.45.67.89

# MX-Record
example.com.            IN  MX  10  mail.example.com.

# SPF-Record
example.com.            IN  TXT     "v=spf1 mx ip4:123.45.67.89 -all"

# PTR-Record (Reverse DNS)
# Beim Provider einrichten: 89.67.45.123 -> mail.example.com

Hostname setzen

# Hostname setzen
hostnamectl set-hostname mail.example.com

# /etc/hosts bearbeiten
echo "123.45.67.89 mail.example.com mail" >> /etc/hosts

# Prüfen
hostname -f
# Ausgabe: mail.example.com

Installation

iRedMail herunterladen

cd /root
wget https://github.com/iredmail/iRedMail/archive/refs/tags/1.6.8.tar.gz
tar -xzf 1.6.8.tar.gz
cd iRedMail-1.6.8

Installation starten

bash iRedMail.sh

Installationsschritte

1. Speicherort für Mailboxen: /var/vmail
2. Webserver: Nginx
3. Backend: MariaDB (empfohlen) oder PostgreSQL
4. Erste Domain: example.com
5. Admin-Passwort: SicheresPasswort!
6. Optionale Komponenten:
   - [X] Roundcube (Webmail)
   - [X] SOGo (Groupware)
   - [X] Fail2ban
   - [X] iRedAdmin (Web-Admin)

Installation abschließen

# System neu starten
reboot

Erste Schritte

Web-Interfaces

Webmail (Roundcube):  https://mail.example.com/mail
SOGo (Groupware):     https://mail.example.com/SOGo
Admin-Panel:          https://mail.example.com/iredadmin
Netdata (Monitoring): https://mail.example.com/netdata

Admin-Login

Benutzer: postmaster@example.com
Passwort: (bei Installation gesetzt)

Wichtige Dateien

/root/iRedMail-1.6.8/iRedMail.tips  # Zugangsdaten
/var/vmail/                          # Mailboxen
/etc/postfix/                        # Postfix-Konfiguration
/etc/dovecot/                        # Dovecot-Konfiguration

DNS vervollständigen

DKIM-Schlüssel abrufen

amavisd-new showkeys

DKIM DNS-Eintrag

dkim._domainkey.example.com. IN TXT "v=DKIM1; p=MIIBIjANBgkqhki..."

DMARC-Eintrag

_dmarc.example.com. IN TXT "v=DMARC1; p=quarantine; rua=mailto:postmaster@example.com"

Alle DNS-Einträge

# A-Record
mail.example.com.           A       123.45.67.89

# MX-Record
example.com.                MX  10  mail.example.com.

# SPF
example.com.                TXT     "v=spf1 mx ip4:123.45.67.89 -all"

# DKIM
dkim._domainkey.example.com. TXT    "v=DKIM1; p=..."

# DMARC
_dmarc.example.com.         TXT     "v=DMARC1; p=quarantine; rua=mailto:postmaster@example.com"

Benutzer verwalten

Über Web-Interface (iRedAdmin)

1. Login: https://mail.example.com/iredadmin
2. Add -> User
3. E-Mail-Adresse und Passwort eingeben

Per Kommandozeile

# MySQL-Datenbank
mysql -u root -p vmail

# Benutzer auflisten
SELECT username, domain, name FROM mailbox;

# Passwort ändern (bcrypt)
UPDATE mailbox SET password='{CRYPT}$2b$...' WHERE username='user@example.com';

Domain hinzufügen

# In iRedAdmin
Add -> Domain

# DNS für neue Domain einrichten
newdomain.com.  MX  10  mail.example.com.
newdomain.com.  TXT     "v=spf1 mx -all"

SSL/TLS-Zertifikate

Let's Encrypt mit Certbot

apt install certbot python3-certbot-nginx

# Zertifikat erstellen
certbot certonly --webroot -w /var/www/html -d mail.example.com

Zertifikate einbinden

# /etc/nginx/sites-available/00-default-ssl.conf

ssl_certificate /etc/letsencrypt/live/mail.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.example.com/privkey.pem;
# /etc/postfix/main.cf

smtpd_tls_cert_file = /etc/letsencrypt/live/mail.example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.example.com/privkey.pem
# /etc/dovecot/dovecot.conf

ssl_cert = </etc/letsencrypt/live/mail.example.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.example.com/privkey.pem

Services neu starten

systemctl restart nginx postfix dovecot

Automatische Erneuerung

# /etc/letsencrypt/renewal-hooks/post/mailserver

#!/bin/bash
systemctl reload nginx postfix dovecot
chmod +x /etc/letsencrypt/renewal-hooks/post/mailserver

Spam-Filter konfigurieren

SpamAssassin

# /etc/spamassassin/local.cf

required_score 5.0
report_safe 0
rewrite_header Subject [SPAM]

# Whitelist
whitelist_from *@trusted-domain.com

# Blacklist
blacklist_from *@spam-domain.com

SpamAssassin aktualisieren

sa-update
systemctl restart amavis

Amavis-Einstellungen

# /etc/amavis/conf.d/50-user

$sa_spam_subject_tag = '[SPAM] ';
$sa_tag_level_deflt  = -999;  # Alle Mails taggen
$sa_tag2_level_deflt = 5.0;   # Spam-Schwelle
$sa_kill_level_deflt = 10;    # Ablehnen

Greylisting

Aktivieren

# /etc/postfix/main.cf

# Postgrey hinzufügen
smtpd_recipient_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    reject_unauth_destination
    check_policy_service inet:127.0.0.1:10023  # Greylisting

Postgrey installieren

apt install postgrey
systemctl enable --now postgrey

Whitelist

# /etc/postgrey/whitelist_clients.local

example.com
trusted-sender.com

Backup

Mailboxen sichern

#!/bin/bash
# /usr/local/bin/backup-mail.sh

DATE=$(date +%Y%m%d)
BACKUP_DIR="/backup/mail"

mkdir -p $BACKUP_DIR

# Mailboxen
tar -czf $BACKUP_DIR/vmail-$DATE.tar.gz /var/vmail/

# Datenbank
mysqldump -u root -pPASSWORD vmail > $BACKUP_DIR/vmail-db-$DATE.sql
mysqldump -u root -pPASSWORD amavisd > $BACKUP_DIR/amavis-db-$DATE.sql

# Konfiguration
tar -czf $BACKUP_DIR/config-$DATE.tar.gz \
    /etc/postfix \
    /etc/dovecot \
    /etc/amavis \
    /etc/nginx

# Alte Backups löschen
find $BACKUP_DIR -type f -mtime +30 -delete

Cron-Job

0 2 * * * /usr/local/bin/backup-mail.sh

Monitoring

Mail-Queue

# Queue anzeigen
mailq
postqueue -p

# Queue leeren
postqueue -f

# Alle Mails löschen
postsuper -d ALL

Logs prüfen

# Postfix
tail -f /var/log/mail.log

# Dovecot
tail -f /var/log/dovecot/dovecot.log

# Amavis
tail -f /var/log/amavis.log

Verbindungstest

# SMTP
telnet mail.example.com 25
openssl s_client -connect mail.example.com:465
openssl s_client -starttls smtp -connect mail.example.com:587

# IMAP
openssl s_client -connect mail.example.com:993

Sicherheit

Fail2ban

# /etc/fail2ban/jail.local

[postfix]
enabled = true
port = smtp,465,587
filter = postfix
logpath = /var/log/mail.log
maxretry = 5
bantime = 3600

[dovecot]
enabled = true
port = pop3,pop3s,imap,imaps
filter = dovecot
logpath = /var/log/dovecot/dovecot.log
maxretry = 5
bantime = 3600

Firewall

# UFW
ufw allow 25/tcp    # SMTP
ufw allow 465/tcp   # SMTPS
ufw allow 587/tcp   # Submission
ufw allow 993/tcp   # IMAPS
ufw allow 995/tcp   # POP3S
ufw allow 80/tcp    # HTTP
ufw allow 443/tcp   # HTTPS

Postfix Hardening

# /etc/postfix/main.cf

# TLS erzwingen
smtpd_tls_security_level = may
smtp_tls_security_level = may

# Rate Limiting
smtpd_client_connection_rate_limit = 10
smtpd_client_message_rate_limit = 30

# Größenbeschränkung
message_size_limit = 52428800  # 50 MB

E-Mail-Client-Einstellungen

IMAP

Server:   mail.example.com
Port:     993
Sicherheit: SSL/TLS
Benutzer: user@example.com

SMTP

Server:   mail.example.com
Port:     587
Sicherheit: STARTTLS
Benutzer: user@example.com

Thunderbird/Outlook

Eingehend (IMAP):
  Server: mail.example.com
  Port: 993, SSL/TLS

Ausgehend (SMTP):
  Server: mail.example.com
  Port: 587, STARTTLS

Troubleshooting

E-Mails werden nicht zugestellt

# Logs prüfen
tail -f /var/log/mail.log

# DNS prüfen
dig MX example.com
dig A mail.example.com

# Port offen?
nc -zv mail.example.com 25

SPF/DKIM/DMARC testen

# Test-E-Mail an
mail-tester.com
# Oder
check-auth@verifier.port25.com

Spam-Score zu hoch

# Header prüfen
X-Spam-Score: 5.2

# SpamAssassin-Details
X-Spam-Status: Yes, score=5.2 required=5.0
    tests=DKIM_SIGNED, DKIM_VALID, SPF_PASS, ...

Blacklist-Check

# Online-Tools:
mxtoolbox.com
multirbl.valli.org

# Per DNS
dig +short txt 89.67.45.123.zen.spamhaus.org

Updates

iRedMail aktualisieren

# Release Notes lesen:
# https://docs.iredmail.org/iredmail.releases.html

# Dann schrittweise Upgrades durchführen

Komponenten aktualisieren

# System-Updates
apt update && apt upgrade -y

# SpamAssassin-Regeln
sa-update

# ClamAV-Signaturen
freshclam

Zusammenfassung

| Port | Dienst | Protokoll | |------|--------|-----------| | 25 | SMTP | Eingehend (Server-to-Server) | | 465 | SMTPS | Ausgehend (SSL) | | 587 | Submission | Ausgehend (STARTTLS) | | 993 | IMAPS | IMAP (SSL) | | 995 | POP3S | POP3 (SSL) |

| URL | Funktion | |-----|----------| | /mail | Roundcube Webmail | | /SOGo | SOGo Groupware | | /iredadmin | Administration |

Fazit

iRedMail bietet eine vollständige Mailserver-Lösung mit minimalem Aufwand. Die Integration von Spam-Filter, Antivirus und Webmail macht sie ideal für kleine bis mittlere Unternehmen. Achten Sie auf korrekte DNS-Einträge (SPF, DKIM, DMARC) für optimale Zustellbarkeit und überwachen Sie regelmäßig die Logs. Für größere Installationen empfiehlt sich die kostenpflichtige iRedMail Pro Version mit zusätzlichen Features.