Biblioteca de cunoștințe

Configuring a mail server: overview Tipărire

  • mail, smtp, postfix, dovecot, dns
  • 0

Overview

Running your own mail server lets you send and receive email for your domains, but it takes careful setup: a mail transfer agent (MTA), an IMAP server for mailboxes, and correct DNS records so other servers trust you. This article covers the components and essential steps on an ALYPOD CPU Pod.

Before you begin

  • A CPU Pod with root/sudo access and a static public IP.
  • One or more domains you control, with DNS access.
  • Ports 25, 465, 587 (SMTP) and 143, 993 (IMAP) allowed in the ALYPOD firewall.
  • Confirm your Pod's IP is not on a blocklist and reverse DNS (PTR) is set appropriately.

The components

  • Postfix — MTA that sends outbound mail and receives inbound SMTP.
  • Dovecot — IMAP/POP3 server providing mailboxes, with LMTP delivery.
  • SpamAssassin / Rspamd — spam filtering.
  • OpenDKIM / OpenDMARC — message signing and authentication.

Steps

  1. Set a proper hostname and mail name:

bash sudo hostnamectl set-hostname mail.example.com echo "mail.example.com" | sudo tee /etc/mailname

  1. Install Postfix and Dovecot:

```bash

Debian / Ubuntu

sudo apt update sudo DEBIAN_FRONTEND=noninteractive apt install -y postfix dovecot-core dovecot-imapd

RHEL family

sudo dnf install -y postfix dovecot ```

  1. Configure Postfix for your domain (in /etc/postfix/main.cf) with myhostname, mydomain, myorigin and mydestination, then start it:

bash sudo systemctl enable --now postfix dovecot sudo systemctl status postfix dovecot

  1. Enable TLS (Let's Encrypt) for SMTP and IMAP so credentials are not sent in the clear.

  2. Configure DNS — these records are essential for deliverability:

  • A / AAAA for mail.example.com.
  • MX for example.com pointing to mail.example.com.
  • PTR (reverse DNS) matching your mail hostname.
  • SPF (TXT): v=spf1 mx -all.
  • DKIM (TXT): your public key, generated by OpenDKIM.
  • DMARC (TXT): v=DMARC1; p=quarantine; rua=mailto:[email protected].
  1. Create mailboxes and virtual domains, then test from an external account:

bash echo "test body" | mail -s "test" [email protected] sudo tail -f /var/log/mail.log

Troubleshooting

  • Problem: Mail lands in spam. Solution: Verify PTR matches the sending hostname, and that SPF, DKIM and DMARC all validate.
  • Problem: Cannot receive mail. Solution: Confirm the MX record and that port 25 is reachable; many networks block 25, so check from an external host.
  • Problem: Outbound mail rejected as coming from a blocked range. Solution: Ensure reverse DNS is set and consider relaying through a trusted smarthost.

Related articles

  • [Setting up a free Let's Encrypt SSL certificate]
  • [Installing cPanel and WHM]
  • [Installing the Nginx web server]

Răspunsul a fost util?

« înapoi