ガイド

真正能抵达收件箱的自建邮件服务器

进阶45分で読めます更新日 2026年6月4日
短い回答

安装邮件服务器很容易;让收件方信任却并非易事。你需要开放25端口、设置与邮件服务器主机名匹配的PTR记录、正确发布SPF、DKIM和DMARC、使用无垃圾邮件历史的IP地址段,并逐步提升发信量。任何一环缺失,邮件都会进入垃圾箱。

01 先设置主机名和反向DNS

Do this before installing anything. The PTR must resolve to the hostname the server announces, and that hostname must have a forward record pointing back to the same address.

hostnamectl set-hostname mail.example.com
# then set the PTR to mail.example.com in the OnionVPS panel

02 安装邮件服务栈

Mailcow gives you a complete Docker-based stack. Stalwart is a single Rust binary if you prefer fewer moving parts.

git clone https://github.com/mailcow/mailcow-dockerized /opt/mailcow
cd /opt/mailcow && ./generate_config.sh
docker compose up -d

03 SPF、DKIM、DMARCを公開する

All three are DNS records. DKIM keys are generated by the mail stack; copy the public key from its admin interface.

example.com.            TXT  "v=spf1 mx -all"
dkim._domainkey        TXT  "v=DKIM1; k=rsa; p=MIGfMA0..."
_dmarc                 TXT  "v=DMARC1; p=none; rua=mailto:[email protected]"

04 预热IP地址

A few dozen messages a day for the first week, then roughly double weekly. A volume spike from a new IP is indistinguishable from a compromised host, and receivers treat it accordingly.

05 报表干净后收紧DMARC

Read aggregate reports for a fortnight at p=none, fix whatever is failing, then move to p=quarantine and eventually p=reject. Going straight to reject reliably breaks systems you forgot were sending mail.

よくある質問

为什么我的邮件会进垃圾箱?

按可能性排序:PTR记录缺失或不匹配、DKIM缺失、新IP发信量过大过快、IP地址段有此前滥用记录。前三种需要你自行修复;第四种是服务商的责任。

我需要静态IP吗?

是的,而且需要能设置反向DNS的静态IP。每位OnionVPS客户的标准配置都包含这两项。