在Ubuntu上部署邮件服务器可参考以下步骤:
准备工作
sudo apt update && sudo apt upgrade -y
。安装核心组件
sudo apt install postfix
,安装时选择“Internet Site”并输入域名。sudo apt install dovecot-core dovecot-imapd dovecot-pop3d
。配置Postfix
/etc/postfix/main.cf
,设置:myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
smtpd_tls_cert_file = /etc/letsencrypt/live/yourdomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/yourdomain.com/privkey.pem
smtpd_use_tls = yes
```。
配置Dovecot
/etc/dovecot/dovecot.conf
,设置:mail_location = maildir:/Maildir
protocols = imap pop3
ssl = yes
ssl_cert = </etc/letsencrypt/live/yourdomain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/yourdomain.com/privkey.pem
```。
启用防火墙
sudo ufw allow 25/tcp # SMTP
sudo ufw allow 143/tcp # IMAP
sudo ufw allow 110/tcp # POP3
sudo ufw reload
。测试与优化
注意:生产环境需进一步配置SASL认证、邮件转发规则,并定期更新系统及软件包。
参考来源: