Debian邮件服务器邮件接收设置主要涉及MTA(邮件传输代理)和MDA(邮件投递代理)配置,以Postfix+Dovecot为例的核心步骤如下:
sudo apt update
sudo apt install postfix dovecot-imapd dovecot-pop3d # 安装Postfix(MTA)和Dovecot(MDA)
/etc/postfix/main.cf,关键参数:myhostname = mail.example.com # 服务器主机名
mydomain = example.com # 域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain # 接收邮件的域名
inet_interfaces = all # 监听所有网络接口
home_mailbox = Maildir/ # 邮件存储路径(Maildir格式)
sudo systemctl restart postfix
/etc/dovecot/dovecot.conf 或 /etc/dovecot/conf.d/10-mail.conf,设置邮件存储路径:mail_location = maildir:~/Maildir # 与Postfix的home_mailbox一致
protocols = imap pop3 # 启用IMAP/POP3协议
ssl = yes
ssl_cert = /etc/ssl/certs/mail.crt
ssl_key = /etc/ssl/private/mail.key
sudo systemctl restart dovecot
sudo ufw allow 25/tcp # SMTP(发送)
sudo ufw allow 143/tcp # IMAP(接收)
sudo ufw allow 993/tcp # IMAPS(加密接收)
sudo ufw allow 110/tcp # POP3(接收)
sudo ufw reload
mail.example.com,端口993,SSL加密mail.example.com,端口995,SSL加密注意:生产环境需额外配置反垃圾邮件(如SpamAssassin)、域名解析(MX记录)、用户认证安全等。
参考来源: