下面给你一套Debian 邮件服务器运维的实战指南,从基础架构到日常维护、排错和安全,偏实用,不堆概念。
最经典的方案(稳定、好维护):
apt update
apt install postfix dovecot-core dovecot-imapd \
dovecot-pop3d mariadb-server \
spamassassin postgrey clamav clamav-daemon
postconf -e "myhostname = mail.example.com"
postconf -e "mydomain = example.com"
postconf -e "myorigin = $mydomain"
postconf -e "inet_interfaces = all"
postconf -e "mydestination = $myhostname, localhost.$mydomain, localhost"
# /etc/dovecot/dovecot.conf
protocols = imap pop3
mail_location = maildir:~/Maildir
systemctl status postfix
systemctl status dovecot
journalctl -u postfix -f
postqueue -p # 查看队列
postsuper -d ALL # 删除所有队列(谨慎)
postcat -q ID # 查看某封邮件内容
tail -f /var/log/mail.log
grep "status=bounced" /var/log/mail.log
postconf -e "smtpd_tls_cert_file=/etc/letsencrypt/live/mail.example.com/fullchain.pem"
postconf -e "smtpd_tls_key_file=/etc/letsencrypt/live/mail.example.com/privkey.pem"
postconf -e "smtpd_tls_security_level=may"
apt install opendkim opendkim-tools
sa-update
systemctl enable postgrey
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf"
/etc/postfix/etc/dovecotrsync -a /var/vmail/ backup:/mail/
mysqldump maildb > maildb.sql
| 问题 | 原因 | 解决 |
|---|---|---|
| 发不出信 | 被拦 / 无 PTR | 配置反向解析 |
| 进垃圾箱 | 无 SPF/DKIM | 配置 DNS |
| 登录失败 | 密码/SSL错 | 查 dovecot 日志 |
| 队列爆满 | 中毒/中继 | 清队列+封IP |
✅ 不用 root 收邮件
✅ 定期更新系统
✅ 监控磁盘(邮件很占空间)
✅ 用 fail2ban 防爆破
✅ 不开放 25 端口给公网登录
如果你愿意,我可以:
你现在是准备搭建还是已经在运维?