测试 Ubuntu 邮件服务器可以从 基本连通性、SMTP 发信、IMAP/POP3 收信、认证与加密、垃圾邮件与反病毒 等多个方面进行。下面按由浅入深的方式给你一套完整测试流程(适用于 Postfix / Dovecot 常见组合)。
systemctl status postfix
systemctl status dovecot
确保都在 active (running)。
ss -lntp
常见端口:
示例:
ss -lntp | grep :25
telnet(最基础)telnet localhost 25
成功后输入:
EHLO test.com
MAIL FROM:<user1@yourdomain.com>
RCPT TO:<user2@yourdomain.com>
DATA
Hello, this is a test.
.
QUIT
✅ 成功标志:返回 250 OK
telnet localhost 143
a login user@yourdomain.com 密码
a list "" "*"
a logout
✅ 成功说明 IMAP 正常
sudo apt install mailutils
echo "Test body" | mail -s "Test subject" user@yourdomain.com
mail
sudo apt install swaks
swaks --to user@yourdomain.com \
--from user@yourdomain.com \
--server mail.yourdomain.com \
--port 587 \
--auth \
--tls
✅ 收到 250 OK 表示认证成功
openssl 测试 IMAPSopenssl s_client -connect localhost:993
登录:
a login user@yourdomain.com password
a select inbox
a logout
mutt 测试(推荐)sudo apt install mutt
mutt -f imaps://user@yourdomain.com@localhost
echo "test" | mail -s "test" xxx@gmail.com
tail -f /var/log/mail.log
重点看:
status=sentdig MX yourdomain.com
dig TXT yourdomain.com
示例:
"v=spf1 mx ~all"
dig TXT default._domainkey.yourdomain.com
dig TXT _dmarc.yourdomain.com
openssl s_client -connect mail.yourdomain.com:465
swaks --server mail.yourdomain.com --port 587 --tls
spamassassin -D --lint
clamdscan test.eml
tail -n 50 /var/log/mail.log
dovecot 认证方式✅ 一键测试 SMTP + TLS + 认证
swaks --to test@gmail.com --server localhost --port 587 --tls --auth
✅ 收信测试
mutt -f imaps://user@domain.com@localhost
如果你愿意,可以告诉我:
我可以给你一份 针对你环境的精确测试清单。