在CentOS中配置郵件服務通常使用Postfix作為SMTP服務器,Dovecot作為IMAP/POP3服務器。具體步驟如下:
sudo yum install postfix dovecot
/etc/postfix/main.cf
文件,設置以下參數:myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/
/etc/dovecot/dovecot.conf
文件,設置以下參數:mail_location = maildir:~/Maildir
auth_mechanisms = plain login
/etc/dovecot/conf.d/10-mail.conf
文件,設置以下參數:mail_location = maildir:~/Maildir
sudo adduser user1
sudo passwd user1
/etc/dovecot/users
文件,添加用戶郵箱賬戶信息:user1:password123
sudo systemctl start postfix
sudo systemctl enable postfix
sudo systemctl start dovecot
sudo systemctl enable dovecot
sudo firewall-cmd --permanent --add-services=smtp
sudo firewall-cmd --permanent --add-service=imap
sudo firewall-cmd --permanent --add-service=pop3
sudo firewall-cmd --reload
完成以上步驟后,您就可以在CentOS上通過郵件客戶端連接到您的郵件服務,并開始發送和接收郵件。