我在使用 Postfix 时遇到了问题。我现在有一台新安装的 Ubuntu 18.04。我安装了 Postfix,在安装过程中,我说邮件应该通过中继发出。由于代理只接受一个域作为发件人,所以我需要一个重写发件人邮件因此我在 main.cf 中添加了这一行:
sender_canonical_classes = envelope_sender, header_sender
sender_canonical_maps = regexp:/etc/postfix/sender_canonical_maps
smtp_header_checks = regexp:/etc/postfix/header_check
# cat /etc/postfix/sender_canonical_maps
/.+/ [email protected]
# cat /etc/postfix/header_check
/From:.*/ REPLACE From: [email protected]
否则我甚至不需要接触配置。Postfix 也是第一次运行,我可以成功测试一切。
它可以运行几分钟甚至几个小时。但到了某个时候,Postfix 就会自动关闭。
查看日志:
# tail -f /var/log/mail.log
Jun 3 09:20:06 my-server postfix/postfix-script[11813]: refreshing the Postfix mail system
Jun 3 09:20:06 my-server postfix/master[7467]: reload -- version 3.3.0, configuration /etc/postfix
Jun 3 09:24:07 my-server postfix/pickup[11826]: 9C62E4209A: uid=33 from=<[email protected]>
Jun 3 09:24:07 my-server postfix/cleanup[11858]: 9C62E4209A: message-id=<JRKi3qQ2QaLr7QtriyHqTzCrODX1JYZ5wh7S1ED9o@umfragen.testbed.gdi-de.org>
Jun 3 09:24:07 my-server postfix/qmgr[11824]: 9C62E4209A: from=<[email protected]>, size=3230, nrcpt=1 (queue active)
Jun 3 09:24:07 my-server postfix/smtp[11860]: 9C62E4209A: replace: header From: Test <[email protected]>: From: [email protected]
Jun 3 09:24:07 my-server postfix/smtp[11860]: 9C62E4209A: to=<[email protected]>, relay=my.proxy[IP.IP.IP.IP]:25, delay=0.07, delays=0.02/0.01/0.01/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A836F285F)
Jun 3 09:24:07 my-server postfix/qmgr[11824]: 9C62E4209A: removed
Jun 3 10:31:06 my-server postfix/postfix-script[20360]: stopping the Postfix mail system
Jun 3 10:31:06 my-server postfix/master[7467]: terminating on signal 15
您可以在这份日志中看到,我已经测试了所有内容,并且在 6 月 3 日 10:31 关闭了 postfix。
因此,如果我现在尝试启动它,该服务将被“屏蔽”
# service postfix start
Failed to start postfix.service: Unit postfix.service is masked.
# systemctl start postfix
Failed to start postfix.service: Unit postfix.service is masked.
如果我尝试取消屏蔽 Postfix。它可以工作,但是 Postfix 不可寻址。
# systemctl unmask postfix.service
Removed /etc/systemd/system/postfix.service.
# systemctl start postfix
# systemctl status postfix
● postfix.service - LSB: Postfix Mail Transport Agent
Loaded: loaded (/etc/init.d/postfix; generated)
Active: active (exited) since Fri 2020-06-05 13:59:57 CEST; 11s ago
Docs: man:systemd-sysv-generator(8)
Process: 17347 ExecStart=/etc/init.d/postfix start (code=exited, status=0/SUCCESS)
Main PID: 7472 (code=exited, status=0/SUCCESS)
Jun 05 13:59:57 my-server systemd[1]: Starting LSB: Postfix Mail Transport Agent...
Jun 05 13:59:57 my-server systemd[1]: Started LSB: Postfix Mail Transport Agent.
# telnet localhost 25
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
对于此进度,mail.log 和 mail.err 中没有新条目
让它再次运行的唯一方法是删除它并清除 apt 并再次安装 postfix。但几分钟或几小时后,postfix 服务又关闭了。
至此,我对此的知识已用尽。
答案1
您可以取消屏蔽并重新启动服务
systemctl unmask postfix.service