postfix 启动失败因无本地接口,需启用 lo 回环、补全 /etc/hosts 映射或设 inet_interfaces = loopback-only;接收本地邮件需正确配置 mydestination 和 smtpd_recipient_restrictions;smtp 认证失败多因 sasl 服务未运行或路径权限错误;发信慢因 25 端口被封,应改用 tls 中继(如 gmail 587 端口)并执行 postmap 刷新。

Postfix 启动失败,systemctl status postfix 显示 fatal: parameter inet_interfaces: no local interface found for 127.0.0.1
这是 Postfix 在没有可用网络接口时的典型报错,常见于最小化安装的 Linux(比如某些云服务器镜像)未启用 lo 回环接口,或 /etc/hosts 缺少 127.0.0.1 localhost 映射。
实操建议:
- 先运行
ip addr show lo确认回环接口是否 up;若为 down,执行sudo ip link set lo up - 检查
/etc/hosts是否含127.0.0.1 localhost,缺就补上(别用::1冲突 IPv6 配置) - 临时绕过:在
/etc/postfix/main.cf中设inet_interfaces = loopback-only,避免 Postfix 主动探测所有接口 - 改完务必运行
sudo postfix check校验语法,再sudo systemctl restart postfix
想让 Postfix 接收本机其他程序发来的邮件(比如 cron、logwatch),但被拒收
默认 Postfix 只监听本地回环(inet_interfaces = loopback-only),但“接收”和“投递”是两回事——关键看 mydestination 和 smtpd_recipient_restrictions。
实操建议:
-
mydestination必须包含本机域名,例如:mydestination = $myhostname, localhost.$mydomain, localhost, example.com - 确保
smtpd_recipient_restrictions包含permit_mynetworks(否则本地网段发信会被拦) - 如果程序用
sendmail -t或mail命令发信,Postfix 的sendmail_path要指向正确路径(通常是/usr/sbin/sendmail.postfix),检查alternatives --config sendmail - 测试命令:
echo "test" | mail -s "local test" root,再查tail -f /var/log/maillog
配置 SMTP 认证后,telnet localhost 25 能连上,但 swaks --to user@example.com --from me@localhost --server localhost 报 535 5.7.8 Error: authentication failed
Postfix 本身不处理 SASL 认证,必须依赖 saslauthd 或 dovecot-sasl。错误不是密码错,而是认证服务没跑、没连上、或机制不匹配。
安装说明重要提醒:程序不支持二级目录安装,请使用一级目录或二级目录绑定!第一步,确定你的服务器支持PHP+mysql。第二步,确定你的服务器开启了gd库。第三步,将upload文件内的文件上传到网站的根目录第四步,访问你的域名+ /install/index.html进行安装,linux系统访问你的域名+ /Install/index.html第五步,按照安装程序步骤进行安装配置第六步,安装完毕后
实操建议:
- 确认
saslauthd已启动:sudo systemctl status saslauthd;若用 Dovecot,启dovecot并确认auth_mechanisms = plain login在/etc/dovecot/conf.d/10-auth.conf - Postfix 的
/etc/postfix/main.cf中必须有:smtpd_sasl_type = dovecot(或saslauthd),且smtpd_sasl_path = private/auth(Dovecot)或smtpd_sasl_path = smtpd(saslauthd) - 权限陷阱:Postfix 进程用户(
postfix)必须对smtpd_sasl_path指向的 socket 文件有读写权,常见于/var/spool/postfix/private/auth所有者不是postfix:dovecot - 调试命令:
testsaslauthd -u username -p password(验证底层认证),再postconf -n | grep sasl检查配置是否生效
Postfix 发信慢,mailq 里积压多,日志反复出现 connect to gmail-smtp-in.l.google.com[142.250.191.69]:25: Connection timed out
这不是 Postfix 问题,是多数家用宽带和云厂商(阿里云、腾讯云、AWS)默认封禁 25 端口出站——尤其针对新注册 IP。Gmail、Outlook 等大厂 SMTP 入口会直接拒绝连接。
实操建议:
- 不要硬刚 25 端口:改用
smtp_tls_security_level = encrypt+smtp_sasl_auth_enable = yes,走smtp.gmail.com:587或smtp.office365.com:587 - 在
/etc/postfix/main.cf加中继配置:relayhost = [smtp.gmail.com]:587,并配好/etc/postfix/sasl_passwd(格式:[smtp.gmail.com]:587 user@gmail.com:app_password) - 注意 Gmail 要用「应用专用密码」而非账户密码,且需开启两步验证;Office365 要确认租户允许 SMTP AUTH
- 强制刷新:运行
sudo postmap /etc/postfix/sasl_passwd,再sudo systemctl reload postfix
最常被忽略的是:以为配了 relayhost 就万事大吉,却忘了 postmap 没执行,或者 sasl_passwd.db 权限是 644(必须 600)导致 Postfix 拒绝读取。









