在CentOS上安装邮件服务器可以通过以下步骤完成,这里以安装Postfix和Dovecot为例:
sudo yum update
sudo yum install postfix dovecot cyrus-sasl
@
,记录值为mail.yourdomain.com
,优先级为1。mail
,记录值为服务器的公网IP地址。/etc/postfix/main.cf
文件,设置以下参数:myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/
/etc/dovecot/dovecot.conf
文件,设置以下参数:protocols = imap pop3
mail_location = maildir:~/Maildir
sudo systemctl start postfix
sudo systemctl enable postfix
sudo systemctl start dovecot
sudo systemctl enable dovecot
sudo systemctl start saslauthd
sudo systemctl enable saslauthd
允许邮件服务相关的端口:
sudo firewall-cmd --permanent --add-service=smtp
sudo firewall-cmd --permanent --add-service=pop3
sudo firewall-cmd --permanent --add-service=imap
sudo firewall-cmd --reload
使用mailx
命令测试发送邮件:
echo "这是一封测试邮件" | mail -s "测试邮件" user@example.com
添加用户并设置密码:
sudo useradd -m user@example.com
sudo passwd user@example.com
使用邮件客户端(如Outlook、Foxmail等)添加自建邮箱,配置SMTP服务器为mail.yourdomain.com
,端口为25。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:CentOS从零开始如何安装Web服务器