什么时候该用这个 postfix.service?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 Postfix config 做 diff。
[Unit] Description=Postfix Mail Transport Agent (main/default instance) Documentation=man:postfix(1) After=network.target nss-lookup.target # network-online.target is a semi-working work-around for specific # network_interfaces, https://bugs.debian.org/854475#126 # Please add local override wanting network-online.target or # systemd-networkd-wait-online@INTERFACE:no-carrier.service #After=network-online.target #Wants=network-online.target ConditionPathExists=/etc/postfix/main.cf # pre-3.9.1-7 multi-instance setup: Conflicts=postfix@-.service [Service] Type=forking # Force operations on single default instance, do not run postmulti wrapper Environment=MAIL_CONFIG=/etc/postfix # perform 2-stage startup ExecStartPre=+postfix check ExecStart=postfix debian-systemd-start ExecStop=postfix stop ExecReload=postfix reload # Postfix consists of multiple processes run by a master(8) orchestrator, # each of them having different requirements. From the whole set, local(8) # (the Postfix local delivery agent) is the most demanding one, because it # runs things as user, and a user needs to be able to run suid/sgid programs # (if not only to be able to deliver mail to /var/spool/postfix/postdrop). # Individual Postfix daemons are started as root, optionally perform chroot # into the queue directory, and drop privileges voluntary # listen(2) on privileged ports (smtp) CapabilityBoundingSet=CAP_NET_BIND_SERVICE # chroot into queue dir CapabilityBoundingSet=CAP_SYS_CHROOT # drop root privs, run as user when delivering local mail CapabilityBoundingSet=CAP_SETGID CAP_SETUID # processes access protected files in non-root-owned dirs (acl root:rwx); CapabilityBoundingSet=CAP_DAC_OVERRIDE # https://bugs.debian.org/1099891 : CapabilityBoundingSet=CAP_DAC_READ_SEARCH # chown(2) is needed for procmal &Co to create /var/mail/$USER CapabilityBoundingSet=CAP_CHOWN # users might run suid/sgid programs from ~/.forward: RestrictSUIDSGID=no # for the same reason, NoNewPrivileges can not be set to yes NoNewPrivileges=no # if you don't use procmail for delivery to /var/mail/$USER, # CAP_CHOWN can be removed. # if you don't use local(8) at all, only doing local delivery over LMTP # or using virtual(8), you can also set #RestrictSUIDSGID=yes #NoNewPrivileges=yes # Also, CAP_DAC_OVERRIDE can be eliminated by adding root user to ACL to # postfix-owned dis in spool: public, private; and whatever maps in protected # subdirs you use, relying on cap_dac_override LockPersonality=yes MemoryDenyWriteExecute=yes ProtectControlGroups=yes ProtectClock=yes PrivateDevices=yes ProtectHostname=yes ProtectKernelLogs=yes ProtectKernelModules=yes ProtectKernelTunables=yes # ProtectProc is not usable with User=root: #ProtectProc=noaccess ProcSubset=pid # ProtectSystem can be "yes" if rw maps are in /etc, or "full" # Alternative would be "strict" +ReadWritePaths=/var ProtectSystem=full # Need to write to ~/Maildir/ etc: ProtectHome=no RestrictAddressFamilies=AF_UNIX AF_NETLINK AF_INET AF_INET6 RestrictNamespaces=yes RestrictRealtime=yes SystemCallFilter=@system-service @setuid chroot [Install] WantedBy=multi-user.target
curl https://exampleconfig.com/api/v1/config/original/9f5642be48b1f6aa33e7e3c511a60d7a?hint=postfix.service
wget -O postfix.service https://exampleconfig.com/api/v1/config/original/9f5642be48b1f6aa33e7e3c511a60d7a?hint=postfix.service
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/9f5642be48b1f6aa33e7e3c511a60d7a?hint=postfix.service' /><config><app>Postfix</app><os>Debian 13 (Trixie)</os><location>/etc/systemd/postfix.service</location><lines>85</lines><md5>9f5642be48b1f6aa33e7e3c511a60d7a</md5><sha256>956ad871586f04750ae6c4ae95db63c192b71baf50d8318b2a2752681306d978</sha256></config></prompt>
粘贴到 Claude、ChatGPT 或任何 AI 助手里。
sudo apk add postfix
sudo apt update && sudo apt install postfix
sudo yum install postfix
sudo apt update && sudo apt install postfix
什么时候该用这个 postfix.service?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 Postfix config 做 diff。
怎么恢复 Postfix 的默认配置?
下载文件,把 /etc/systemd/postfix.service 里的当前配置备份好,替换掉,然后 reload 或 restart Postfix。
postfix.service 适合直接上生产吗?
这是 Debian 13 (Trixie) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Debian 13 (Trixie)。
我可以用它来排查 Postfix 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。