什么时候该用这个 main.cf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 Postfix config 做 diff。
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 3.6 on
# fresh installs.
compatibility_level = 3.6
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = 427ca3f96c0d
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, 427ca3f96c0d, localhost.localdomain, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
curl https://exampleconfig.com/api/v1/config/original/c0785e7a04bdc80485c3c720fbba9cf8?hint=main.cf
wget -O main.cf https://exampleconfig.com/api/v1/config/original/c0785e7a04bdc80485c3c720fbba9cf8?hint=main.cf
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/c0785e7a04bdc80485c3c720fbba9cf8?hint=main.cf' /><config><app>Postfix</app><os>Ubuntu 24.04 LTS (Noble Numbat)</os><location>/etc/postfix/main.cf</location><lines>46</lines><md5>c0785e7a04bdc80485c3c720fbba9cf8</md5><sha256>0495929261e4dc7f5e2c24e5faa2da19d7e46d6f86b550e76e690f2f7d7cc34a</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
什么时候该用这个 main.cf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 Postfix config 做 diff。
怎么恢复 Postfix 的默认配置?
下载文件,把 /etc/postfix/main.cf 里的当前配置备份好,替换掉,然后 reload 或 restart Postfix。
main.cf 适合直接上生产吗?
这是 Ubuntu 24.04 LTS (Noble Numbat) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Ubuntu 24.04 LTS (Noble Numbat)。
我可以用它来排查 Postfix 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。