调试 Ubuntu 邮件服务(通常指 Postfix / Sendmail / Exim / Dovecot 等)可以按下面系统化的思路来做。下面以最常见的 Postfix + Dovecot 为例,兼顾通用方法。
systemctl status postfix
systemctl status exim4
systemctl status sendmail
systemctl status dovecot
常见组合:
systemctl status postfix
systemctl status dovecot
没运行就启动:
sudo systemctl start postfix
sudo systemctl enable postfix
sudo netstat -tunlp | grep -E '25|110|143|465|587|993'
常见端口:
sudo tail -f /var/log/mail.log
sudo journalctl -u postfix -f
sudo tail -f /var/log/mail.log
sudo journalctl -u dovecot -f
发一封测试邮件,然后立刻看日志:
echo "test" | mail -s "test" user@example.com
mail -s "hello" user@localhost
telnet localhost 25
示例:
HELO localhost
MAIL FROM:<test@localhost>
RCPT TO:<user@localhost>
DATA
Subject: test
hello
.
QUIT
检查:
nslookup example.com
sudo ufw status
mailq
postqueue -p
清空队列(谨慎):
postsuper -d ALL
检查:
sudo dovecot -n
常见错误:
测试登录:
telnet localhost 143
postfix check
postconf -n
编辑:
sudo nano /etc/postfix/main.cf
加入:
debug_peer_level = 3
重启:
sudo systemctl restart postfix
swaks --to user@example.com --from test@localhost --server localhost
你可以告诉我:
/var/log/mail.log)我可以帮你逐行分析日志并定位问题。