Postfix 3.6.4 配置参数详解

Postfix 3.6.4 main.cf 核心参数逐项实测:网络监听、收信域、中继控制、虚拟域、TLS 自签、SASL 认证与反垃圾,每项含 postconf -e 修改-验证-还原闭环

Postfix邮件服务器SMTPPostfix邮件2026/10/26

Postfix 3.6.4 配置参数详解

目标:系统讲解 Postfix 3.6.4(Ubuntu 22.04 仓库版 3.6.4-1ubuntu1.4)main.cf 核心参数,覆盖网络监听、收信域、中继控制、虚拟域、TLS、SASL 认证与反垃圾参数,每个参数均给出「postconf -e 修改 → postconf -h / 实际收发验证 → 还原」的实测闭环。实测日期 2026-10-26,环境与《Ubuntu 22.04 安装 Postfix 3.6.4 指南》一致(双机 mail1.example.com / mail2.example.com)。

一、环境信息

项目值
操作系统Ubuntu 22.04 LTS(amd64)
Postfix 版本3.6.4-1ubuntu1.4(postconf mail_version 实测 3.6.4,compatibility_level 3.6)
实测主机mail1.example.com(10.89.57.11,本域 example.com);mail2.example.com(10.89.57.12,本域 example.net)
主配置/etc/postfix/main.cf(本文主角)、/etc/postfix/master.cf(进程定义)
表文件目录/etc/postfix/(transport、virtual、aliases 的 hash 库生成源)
日志/var/log/mail.log

所有回显均逐行照抄自实测。除特别说明外,参数修改动作统一为 postconf -e "参数 = 值",生效动作为 postfix reload,查看动作为 postconf -h 参数名。

二、配置文件体系与操作方法

2.1 main.cf 与 master.cf 的分工

  • main.cf:全部运行参数(约 800 个,绝大多数有内置默认值),键值对形式,# 注释;
  • master.cf:进程装配清单(哪个服务、几个进程、是否 chroot),SMTP 监听、postscreen、投递代理都在这里定义。

查看「与内置默认值不同」的生效参数用 postconf -n(全新安装的完整回显见安装指南 4.4 节);查看任意参数当前值用 postconf -h 参数名;查看内置默认值用 postconf -d 参数名:

postconf -d message_size_limit

实测回显:

message_size_limit = 10240000

2.2 修改与生效:postconf -e、-X 与 reload

postconf -e 写回 main.cf,postconf -X 参数名 把参数从 main.cf 删除(恢复内置默认),改完必须 reload。以 relayhost 为例走一遍完整生命周期(mail2 实测):

postconf -h relayhost

实测回显(默认为空,输出空行):

postconf -e "relayhost = [mail1.example.com]"
postconf -h relayhost

实测回显:

[mail1.example.com]

验证真实效果——发往无关外域的信全部改经 mail1 转出(mail2 日志实测,status=sent 表示「已成功交给中继」):

Oct 26 10:56:35 mail2 postfix/smtp[4516]: 7C6023E784F: to=<them@foreign.example>, relay=mail1.example.com[10.89.57.11]:25, delay=0.04, delays=0.01/0.01/0.01/0.01, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 840023E7852)

mail1 收下后继续向目标投递(内网无公网 DNS,退信 dsn=5.4.4 属预期边界行为,mail1 日志实测):

Oct 26 10:56:35 mail1 postfix/smtp[6514]: 840023E7852: to=<them@foreign.example>, relay=none, delay=0.15, delays=0/0.01/0.14/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=foreign.example type=AAAA: Host found but no data record of requested type)

两行连读即 relayhost 的完整语义:mail2 把出站流量劫持到 mail1(relay 字段从 none 变为 relay=mail1.example.com),退信发生在最后一跳。删除参数恢复默认:

postconf -X relayhost
postconf -h relayhost

实测回显(回到空):

2.3 参数值中的变量与查表语法

main.cf 值里可用 $参数名 引用其他参数(如 smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu))。表类参数用 type:path 形式:hash:/etc/postfix/virtual 表示用 postmap 编译的 Berkeley DB,改表后必须重新 postmap 并 reload。

三、网络与监听参数

3.1 myhostname:本机主机名

默认由安装器按系统主机名生成。修改并验证(mail2 实测):

postconf -h myhostname
postconf -e "myhostname = mx1.example.net"
postconf -h myhostname

实测回显:

mail2.example.com
mx1.example.net

SMTP 横幅与日志中的主机名随它变化。还原:

postconf -e "myhostname = mail2.example.com"

3.2 smtpd_banner:220 横幅

默认 $myhostname ESMTP $mail_name (Ubuntu)。客户端连接时看到的第一行就是它:

swaks --server mail2.example.com --to nobody@example.net

实测回显(关键行):

<-  220 mail2.example.com ESMTP Postfix (Ubuntu)

改成低调横幅并验证:

postconf -e "smtpd_banner = \$myhostname ESMTP Mail Service Ready"
postconf -h smtpd_banner

实测回显:

$myhostname ESMTP Mail Service Ready
postconf -e "smtpd_banner = \$myhostname ESMTP \$mail_name (Ubuntu)"

(注意 shell 双引号内 $ 要转义为 \$,否则会被 shell 展开。)

3.3 inet_interfaces 与 inet_protocols

默认 inet_interfaces = all、inet_protocols = all(全新安装回显见安装指南 4.4 节)。专用中继机可改成只监听内网地址(inet_interfaces = 10.89.57.12),改完必须 reload 且注意 master.cf 里 smtp 行会受其影响。

四、收信域与本地投递参数

4.1 mydestination:本机接收哪些域

决定「什么收件地址算本域信」。全新安装的实测形态:

mydestination = $myhostname, mail1.example.com, localhost.example.com, , localhost

注意中间有一个空项(连续逗号),是安装器按主机名拆分生成的,无功能影响。移除某域的实测效果:把 example.net 从 mail2 的 mydestination 摘除后,发往 root@example.net 的信不再本地投递,而按「非本域」走转发链路(客户端 IP 在 mynetworks 内所以被放行转发,随后因外域不可解析退信):

Oct 26 10:55:40 mail2 postfix/smtp[6318]: 9F1CC3E7847: to=<root@example.net>, relay=none, delay=0.09, delays=0/0.01/0.08/0, dsn=5.4.4, status=bounced (Domain example.net does not accept mail (nullMX))

恢复 mydestination 后同一收件地址立即恢复本地投递(250 Ok)。结论:mydestination 变化直接改变收信资格,生产上把本域列全,别依赖拆分推导。

4.2 myorigin 与 /etc/mailname

本机发信的默认补齐域:

cat /etc/mailname
postconf -h myorigin

实测回显:

mail1.example.com
/etc/mailname

root 发信自动变成 root@mail1.example.com(mbox 头 Return-Path 实证见安装指南 4.6 节)。

4.3 alias_maps / alias_database:系统别名

/etc/aliases 实测内容(mail1,行 2-3):

postmaster:    root
webmaster: admin

(webmaster 指向 admin——8.1 节创建的 SASL 演示账号,本地真实用户。)追加别名后重建并查询:

newaliases
postalias -q webmaster /etc/aliases

实测回显:

admin

本地投递日志中显示改写痕迹(orig_to 保留原始收件人):

Oct 26 09:52:57 mail1 postfix/local[4719]: 7C6683E07B4: to=<admin@mail1.example.com>, orig_to=<webmaster>, relay=local, delay=0, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)

4.4 mailbox_size_limit 与 message_size_limit

mailbox_size_limit 默认 0(不限制),message_size_limit 默认 10 MB。把消息上限压到 100 KB 的实测闭环(mail2):

postconf -e "message_size_limit = 102400"
postfix reload
dd if=/dev/zero of=/tmp/big bs=1024 count=200
swaks --to root@example.net --server mail2.example.com --body /tmp/big

实测回显(关键行):

<** 552 5.3.4 Error: message file too big

日志侧影( smtpd 按消息级队列 ID 记告警):

Oct 26 10:56:30 mail2 postfix/smtpd[4476]: warning: 790713E784F: queue file size limit exceeded

(SMTP 层对客户端同步回 552 5.3.4,见上方对话回显。)删除限制参数后恢复默认:

postconf -X message_size_limit
postconf -h message_size_limit

实测回显:

10240000

五、中继与访问控制参数

5.1 mynetworks:信任客户端网段

默认只含回环(127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128)。把内网网段加入:

postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.89.57.0/24"
postconf -h mynetworks

实测回显:

127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.89.57.0/24

效果实测:网段内客户端向无关外域发起中继,从被拒到放行——

  • 加入前(mail2 收到 mail1 的中继请求):
<** 454 4.7.1 <user@foreign.example>: Relay access denied
  • 加入后:
<-  250 2.0.0 Ok: queued as 885253E0077

5.2 smtpd_relay_restrictions:中继三段防线

默认值(全新安装实测):

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

语义:信任网段放行 → SASL 认证用户放行 → 未授权中继延迟拒绝(454 4.7.1)。这是防「开放中继」的第一道链,只管收件人地址是否允许中继,不判内容。擅自重写该链前先用 5.1 的两个实测输出当验收标准。

5.3 smtpd_recipient_restrictions:内容层访问控制

默认空(仅 relay_restrictions 生效)。常见增强是在 RCPT 阶段拒绝发件域不存在的信:

postconf -e "smtpd_recipient_restrictions = reject_unknown_sender_domain, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination"

💡 注意三个 reject 的顺序语义:reject_unknown_sender_domain 挡伪造域,permit_* 放行合法来源,reject_unauth_destination 兜底拒绝中继。测完恢复默认:postconf -X smtpd_recipient_restrictions。

5.4 transport_maps:按收件域指定出站路径

表文件 + postmap 编译 + 参数引用三步(mail1 实测):

cat >> /etc/postfix/transport <<'EOF'
example.net    relay:[mail2.example.com]
EOF
postmap /etc/postfix/transport
postconf -e "transport_maps = hash:/etc/postfix/transport"
postmap -s hash:/etc/postfix/transport

实测回显(列出表内容):

example.net	relay:[mail2.example.com]

投递日志实证(发往 example.net 的信交给 mail2,relay 字段指向它):

Oct 26 09:48:19 mail1 postfix/relay/smtp[4304]: 4AF6D3E066A: to=<root@example.net>, relay=mail2.example.com[10.89.57.12]:25, delay=0.02, delays=0/0.01/0/0, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 4E34E3E06A2)

relay:[...] 的方括号表示跳过 MX 查询、直接连主机 A 记录,内网固定拓扑推荐。

5.5 relayhost:全局出站中继

与 transport_maps 的关系:relayhost 是「全局默认出站路由」,transport_maps 是「按域精细路由」,后者优先。实测闭环见 2.2 节(relay 字段从 none 变为 relay=mail1.example.com,改回后日志恢复 relay=none)。

六、虚拟域与别名改写参数

6.1 virtual_alias_domains:宣告虚拟域

虚拟域(不在 mydestination、本机代收但不属于任何系统用户)在 Postfix 3.6 用 virtual_alias_domains 宣告,信件只做地址改写后转交,不占用 virtual(8) 投递代理。实测配置(mail1):

postconf -e "virtual_alias_domains = example.org"
postconf -h virtual_alias_domains

实测回显:

example.org

6.2 virtual_alias_maps:虚拟地址改写表

表文件实测内容(/etc/postfix/virtual):

info@example.org	admin@example.com
postmaster@example.org	root
contact@example.org	root@example.com, admin@example.com

(第三行是多目标改写示例:一封信复制给两个收件人。)编译与生效:

postmap /etc/postfix/virtual
postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
postfix reload

验证一:单目标改写——发 info@example.org,日志显示 to 与 orig_to:

echo "virtual check body" | mail -s "virtual-check" info@example.org

实测回显(mail.log):

Oct 26 11:11:49 mail1 postfix/local[6700]: 6E1E33E14D9: to=<admin@example.com>, orig_to=<info@example.org>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)

验证二:多目标改写——发 contact@example.org,一次投递分裂为两封信(实测第二封日志):

Oct 26 11:12:38 mail1 postfix/local[6700]: E70953E14DE: to=<root@example.com>, orig_to=<contact@example.org>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)

6.3 虚拟域 vs mydestination vs 别名 选型

机制收件域归属改写对象典型用途
mydestination本机本地域无系统用户收信
/etc/aliases本地域内系统用户短名 → 真实用户root 分流、组列表
virtual_alias_*任意虚拟域完整邮件地址 → 一个或多个地址多域名托管、销售邮箱映射

七、TLS 配置参数

7.1 自签证书生成与部署

内网/测试环境可用自签证书(公网服务请用 Let's Encrypt 等受信 CA)。生成一对证书与私钥(mail1 实测):

mkdir -p /etc/postfix/tls
openssl req -newkey rsa:2048 -nodes -x509 -days 365 \
  -keyout /etc/postfix/tls/mail1.key -out /etc/postfix/tls/mail1.crt \
  -subj "/C=CN/ST=Beijing/O=Example/CN=mail1.example.com"

实测回显(RSA 密钥点阵进度 + 分隔线,其余无输出):

....+...++++++...(点阵省略)
-----

文件落盘与权限核对:

ls -la /etc/postfix/tls/

实测回显:

total 16
drwxr-xr-x 2 root root 4096 Oct 26 09:49 .
drwxr-xr-x 6 root root 4096 Oct 26 10:49 ..
-rw-r--r-- 1 root root 1269 Oct 26 11:11 mail1.crt
-rw------- 1 root root 1704 Oct 26 11:11 mail1.key

证书信息核对:

openssl x509 -in /etc/postfix/tls/mail1.crt -noout -subject -dates

实测回显:

subject=C = CN, ST = Beijing, O = Example, CN = mail1.example.com
notBefore=Oct 26 11:11:46 2026 GMT
notAfter=Oct 26 11:11:46 2027 GMT

7.2 smtpd_tls_*:对外(smtpd)TLS 参数

postconf -e "smtpd_tls_cert_file = /etc/postfix/tls/mail1.crt"
postconf -e "smtpd_tls_key_file = /etc/postfix/tls/mail1.key"
postconf -e "smtpd_tls_security_level = may"
postfix reload

may = 机会性 TLS(客户端支持即加密,不支持也放行收发),是收公网信的推荐级别;encrypt = 强制 TLS(只对自家客户端网段的专用通道用,否则公网大量服务器连不上你)。验证 EHLO 里出现 STARTTLS:

swaks --server mail1.example.com --to nobody@example.com

实测回显(关键行):

<-  250-PIPELINING
<-  250-STARTTLS

TLS 握手实测(openssl 客户端视角):

echo | openssl s_client -starttls smtp -connect mail1.example.com:25 -brief

实测回显:

depth=0 C = CN, ST = Beijing, O = Example, CN = mail1.example.com
verify error:num=18:self-signed certificate
CONNECTION ESTABLISHED
Protocol version: TLSv1.3
Ciphersuite: TLS_AES_256_GCM_SHA384
Peer certificate: C = CN, ST = Beijing, O = Example, CN = mail1.example.com

verify error:num=18 是自签证书的预期校验失败;协议版本 TLSv1.3、套件 AES-256-GCM 说明握手成功。日志侧会记 Anonymous TLS connection established from ...: TLSv1.3 with cipher ...。

7.3 smtp_tls_*:对出站(smtp)TLS 参数

默认(全新安装实测):smtp_tls_security_level = may、smtp_tls_CApath = /etc/ssl/certs、smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache。含义:本机作为客户端向其他服务器发信时也做机会性 TLS。生产公网发信可升级为 smtp_tls_security_level = dane(依赖 DNSSEC)或 verify。

7.4 smtpd_tls_auth_only:认证必须走加密

postconf -e "smtpd_tls_auth_only = yes"

设为 yes 后,明文 EHLO 不通告 AUTH(实测:swaks 不带 TLS 时报):

*** Host did not advertise authentication

带 STARTTLS 后才出现认证能力(见 8.4 节 235 实测)。这是防止账号口令明文上线路的关键参数。

八、SASL 认证配置参数

Postfix 自身不校验密码,需配 SASL 实现。本节用 Cyrus SASL(saslauthd + 系统口令 shadow)实测,形态简化(未用 dovecot),认证用户为系统用户 admin(口令 q1w2e3r4)。

8.1 准备:安装 saslauthd 与认证账号

apt-get install -y sasl2-bin
useradd -m -s /usr/sbin/nologin admin
echo "admin:q1w2e3r4" | chpasswd

8.2 /etc/postfix/sasl/smtpd.conf:Postfix 侧 SASL 配置

pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

8.3 chroot 套接字排障实录(jammy 两个坑)

坑一:Ubuntu 22.04 的 /etc/default/saslauthd 已没有 START 开关行,init 脚本只会提示但不启动——手工追加 START=yes 后再 service saslauthd start。

坑二:master.cf 里 smtp 服务默认 chroot=y,smtpd 在 chroot 内只能看到 /var/spool/postfix 下的路径,saslauthd 套接字必须落在 chroot 内。修复前实测:

testsaslauthd -u admin -p q1w2e3r4
0: connect() : No such file or directory
<** 454 4.7.0 Temporary authentication failure: generic failure

修复动作(把套接字目录挪进 chroot 并授权):

sed -i 's/^OPTIONS=""/OPTIONS="-c -m \/var\/spool\/postfix\/var\/run\/saslauthd"/' /etc/default/saslauthd
mkdir -p /var/spool/postfix/var/run/saslauthd
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd
adduser postfix sasl
service saslauthd restart

修复后实测(套接字就位 + 独立认证测试通过):

ls /var/spool/postfix/var/run/saslauthd/
testsaslauthd -u admin -p q1w2e3r4

实测回显:

mux  mux.accept  cache.flock  cache.mmap  saslauthd.pid
0: OK "Success."

8.4 smtpd_sasl_* 参数组

postconf -e "smtpd_sasl_auth_enable = yes"
postconf -e "smtpd_sasl_type = cyrus"
postconf -e "smtpd_sasl_path = smtpd"
postconf -e "smtpd_tls_auth_only = yes"
postfix reload
postconf -h smtpd_sasl_auth_enable smtpd_sasl_type smtpd_sasl_path

实测回显:

yes
cyrus
smtpd

(smtpd_sasl_path = smtpd 指向 /etc/postfix/sasl/smtpd.conf;saslauthd 进程实测形态:4655 /usr/sbin/saslauthd -a shadow -c -m /var/spool/postfix/var/run/saslauthd -n 5。)

认证成功对话(swaks 走 STARTTLS 后 AUTH LOGIN):

<~  235 2.7.0 Authentication successful

日志侧影(client 行记录认证身份,permit_sasl_authenticated 放行其外域中继):

Oct 26 11:11:02 mail1 postfix/smtpd[6601]: 267B53E13CE: client=mail1.example.com[10.89.57.11], sasl_method=LOGIN, sasl_username=admin

密码错误对话实测:

<** 535 5.7.8 Error: authentication failed: authentication failure

配套把 smtpd_relay_restrictions 里的 permit_sasl_authenticated 保持在 defer_unauth_destination 之前(默认值已如此),漫游用户即可在任意网络凭账号发信。

九、连接与反垃圾参数

9.1 postscreen:连接前置过滤

postscreen 在 smtpd 之前接管 25 端口,用「先搭讪观察」的方式过滤僵尸网络客户端(PREGREET 检测抢先发命令的客户端)。在 master.cf 追加独立监听口(标准配置):

2525     inet  n       -       y       -       1       postscreen
smtpd     pass  -       -       y       -       -       smtpd
dnsblog   unix  -       -       y       -       0       dnsblog
tlsproxy  unix  -       -       y       -       0       tlsproxy
postconf -e "postscreen_greet_banner = \$myhostname ESMTP Postscreen"
postfix reload
swaks --to root@example.com --server mail1.example.com --port 2525

实测回显(正常客户端通过 postscreen 后被移交 smtpd,完整 SMTP 会话):

<-  220 mail1.example.com ESMTP Postfix (Ubuntu)

日志侧影(CONNECT 记录 + 通过后进入临时放行名单):

Oct 26 10:49:41 mail1 postfix/postscreen[6136]: CONNECT from [10.89.57.11]:54350 to [10.89.57.11]:2525
Oct 26 10:49:41 mail1 postfix/postscreen[6136]: ALLOWLISTED [10.89.57.11]:54350

关键默认值(postconf -d 实测):postscreen_greet_wait = ${stress?{2}:{6}}s(系统繁忙时自动收缩观察窗)、postscreen_greet_banner = $smtpd_banner、postscreen_non_smtp_command_action = drop(非 SMTP 命令直接断开)。

⚠️ 实测边界:PREGREET/DNSBL 拦截依赖真实恶意客户端时序与可达的公网 DNSBL 服务;本实验环境(内网 DNS 受限、客户端为正常工具)仅验证了「正常客户端放行链路」与上述默认参数。生产启用 postscreen 前应先 postscreen_whitelist_interfaces 观察模式运行一段时间,避免误伤。

9.2 reject_rbl_client:DNS 黑名单

把客户端地址提交 RBL 实时黑名单查询(例:zen.spamhaus.org):

postconf -e "smtpd_client_restrictions = reject_rbl_client zen.spamhaus.org"
postfix reload

实测边界行为:在公网 DNS 不可达的环境,DNSBL 查询失败按 fail-open 处理——客户端不被拒绝,信件照常入队(实测 250 2.0.0 Ok: queued as 4B7B43E7849),且日志无告警。结论:RBL 不是「挂上就生效」的开关,它依赖对外 DNS 查询质量;查询超时会拉长每次连接的判定时间,公网部署要给 DNS 缓存留余量。测完恢复:postconf -X smtpd_client_restrictions。

十、参数修改流程与回滚

10.1 标准动作序列

  1. postconf -n > /tmp/main.cf.before(修改前留档);
  2. postconf -e "参数 = 值" 逐项修改;
  3. postconf 参数名 核对写入值;
  4. postfix check 静默通过(退出码 0)确认语法;
  5. systemctl reload postfix(不断开在途连接);
  6. 用收发实测验证行为(本文各节闭环);

10.2 回滚

  • 单参数回滚:postconf -X 参数名 恢复内置默认(本文 relayhost、message_size_limit、smtpd_client_restrictions 三处实测);
  • 整文件回滚:cp /tmp/main.cf.before /etc/postfix/main.cf && systemctl reload postfix。

10.3 compatibility_level:升级保护阀

默认 compatibility_level = 3.6(与版本号同步,全新安装实测)。升级 Postfix 大版本后旧行为按此级别锁定不变,日志会以 using backwards-compatible default setting 提示可迁移项;主动调高前逐条读官方兼容性说明。

十一、常见问题(排障实录)

Q1:改了 main.cf 完全没生效? 没 reload。Postfix 不会热读配置,必须 systemctl reload postfix;验证用 postconf -h 参数名 看运行值而不是看文件。

Q2:postconf -e 值里的 $ 变量被改坏了? shell 双引号里 $myhostname 会被 shell 展开成实际值写进文件。要么单引号 postconf -e 'smtpd_banner = $myhostname ESMTP',要么 \$ 转义(本文 3.2 节实测两种形态)。

Q3:SASL 一直 454 4.7.0 Temporary authentication failure? chroot 套接字问题(8.3 节坑二完整实录):saslauthd 的 mux 套接字不在 /var/spool/postfix/var/run/saslauthd,smtpd 在 chroot 里连不到。用 testsaslauthd 与 ls 逐步定位。

Q4:AUTH 能力通告不出来? smtpd_tls_auth_only = yes 时必须先 STARTTLS(3.4 节实测 *** Host did not advertise authentication)。客户端开 TLS 或临时 postconf -e "smtpd_tls_auth_only = no" 验证链路。

Q5:RBL 挂了但垃圾邮件照样进? DNSBL 查询失败 fail-open(9.2 节实测 250 放行)。先确认能解析 zen.spamhaus.org 且不在公共解析器封禁名单,再看日志是否出现 reject_rbl_client 拒绝记录。

Q6:552 5.3.4 Error: message file too big? message_size_limit 生效(4.4 节实测闭环),附件场景按 1.33 倍编码放大后估容,或调回 10240000。

Q7:虚拟域改写不生效? postmap 没跑或 reload 没做。postmap -s hash:/etc/postfix/virtual 先确认表内容(6.2 节实测回显),再 postconf -h virtual_alias_maps 确认引用路径一致。

Q8:中继想精确到「只允许某台主机」? mynetworks 用 CIDR 粒度(5.1 节实测 10.89.57.0/24);单主机直接写 IP。白名单精确控制后再叠加 smtpd_relay_restrictions 的认证通道,两条路并行不冲突。

十二、参考链接

  1. Postfix 官方参数手册 postconf(5):https://www.postfix.org/postconf.5.html
  2. Postfix SASL README:https://www.postfix.org/SASL_README.html
  3. Postfix TLS README:https://www.postfix.org/TLS_README.html
  4. Postfix Postscreen README:https://www.postfix.org/POSTSCREEN_README.html
  5. 站内同族实战:《Ubuntu 22.04 安装 Postfix 3.6.4 指南》(环境与安装)、《Postfix 3.6.4 常用 CLI 命令详解》(命令矩阵)、《Mailcow 2026-09a 介绍与选型指南》