在CentOS上部署邮件服务器是一个复杂但非常有意义的任务,以下是详细的步骤和注意事项:
sudo yum update -y
sudo yum install postfix dovecot mariadb-server mariadb -y
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE mail;
USE mail;
CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL);
GRANT SELECT, INSERT, UPDATE, DELETE ON mail.* TO 'mailuser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;
/etc/postfix/main.cf
文件,设置以下参数:myhostname mail.example.com
mydomain example.com
myorigin mydomain
inet_interfaces all
inet_protocols ipv4
mydestination myhostname, localhost.mydomain, localhost, mydomain
home_mailbox Maildir/
smtpd_banner myhostname ESMTP
smtpd_recipient_restrictions permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable yes
smtpd_sasl_security_options noanonymous
smtpd_sasl_type dovecot
smtpd_sasl_path private/auth
smtpd_sasl_local_domain myhostname
sudo systemctl start postfix
sudo systemctl enable postfix
/etc/dovecot/dovecot.conf
文件,设置以下参数:protocols imap pop3
mail_location maildir:/Maildir
/etc/dovecot/conf.d/10-mail.conf
文件,设置以下参数:mail_location maildir:/Maildir
sudo systemctl start dovecot
sudo systemctl enable dovecot
sudo firewall-cmd --permanent --add-services=smtp
sudo firewall-cmd --permanent --add-service=pop3
sudo firewall-cmd --permanent --add-service=imap
sudo firewall-cmd --reload
wget https://github.com/roundcube/roundcube/releases/download/v1.3.12/roundcube-1.3.12.tar.gz
tar xvf roundcube-1.3.12.tar.gz
cd roundcube-1.3.12
./configure
make
sudo make install
sudo cp config/config.inc.php.sample config/config.inc.php
netstat -ntlp | grep :25
netstat -ntlp | grep :110
mail.example.com
,端口为 587
,并使用配置的邮箱和密码进行测试。/var/log/maillog
,查找具体的错误信息,常见的问题包括DNS解析失败、防火墙拦截等。/etc/postfix/main.cf
文件,添加或修改以下行:message_size_limit 10485760 # 例如10MB
然后重启Postfix服务以使更改生效。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: centos sftp传输速度慢如何优化