降低 Debian 邮件服务器负载的核心是减少不必要的邮件处理、防止垃圾邮件、限制队列积压并优化配置。下面按常见场景给出可操作的建议。
先确定是 CPU/IO 高 还是 邮件队列堆积。
top
htop
iotop
查看邮件队列:
postqueue -p # Postfix
mailq
如果队列里大量邮件,通常是:
Postfix 检查:
postconf smtpd_relay_restrictions
推荐配置:
smtpd_relay_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination
⚠️ 绝不要使用:
permit_auth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
default_process_limit = 50
smtpd_client_connection_count_limit = 3
smtpd_client_connection_rate_limit = 10
smtpd_client_message_rate_limit = 20
message_size_limit = 10485760 # 10MB
smtpd_recipient_restrictions =
permit_mynetworks,
reject_rbl_client zen.spamhaus.org,
reject_rbl_client bl.spamcop.net,
permit
⚠️ 先测试,避免误杀
apt install spamassassin spamc
Postfix 调用:
content_filter = spamassassin
ClamAV 非常吃资源,如非必要可关闭:
systemctl disable clamav-daemon
systemctl stop clamav-daemon
vim /etc/aliases
newaliases
避免:
root: user1,user2,...
local_destination_concurrency_limit = 2
queue_run_delay = 300s
minimal_backoff_time = 300s
maximal_backoff_time = 3600s
postsuper -d ALL deferred
⚠️ 会丢弃未发送邮件
如果是 Web 服务器:
mail(),改用 SMTP + 认证grep -R "mail(" /var/www
grep "from=" /var/log/mail.log | awk '{print $6}' | sort | uniq -c | sort -nr
grep "reject" /var/log/mail.log
systemctl stop postfix
iptables -A INPUT -p tcp --dport 25 -j DROP
✅ 不开放中继
✅ 启用认证
✅ 限制连接与频率
✅ 使用 RBL
✅ 关闭不必要的反病毒
✅ 定期清理队列
如果你愿意,可以告诉我:
我可以给你一份针对你服务器的精简配置模板。