搭建支持Web客户端的邮件服务器(Postfix + OpenWebMail)
邮箱地址为:用户名@sziit2003010211.cn
Postfix的配置见上一篇笔记——支持邮件客户端的邮件服务器
OpenWebMail的配置可直接进入官网查看官方README配置文档https://openwebmail.org/openwebmail/download/centos/el8/
Shell
#/bin/bash#配置DNSdnf install bind -yip='192.168.11.100' # 部署的主机的IPsed -i "s/listen-on port.*};/listen-on port 53 { ${ip}; };/" /etc/named.confsed -i 's/allow-query.*};/allow-query { any; };/' /etc/named.confdomain='sziit2003010211.cn' # 配置的邮件服务器要使用的域名sed -i '$a zone \'"\"${domain}\" IN {\n\ttype master;\n\tfile \"${domain}.zone\";\n};" /etc/named.rfc1912.zonesdns_conffile="/var/named/${domain}.zone"cp -p /var/named/named.empty ${dns_conffile}sed -i 's/rname.invalid/hczyyds@qq.com/' ${dns_conffile}sed -i "s/127.0.0.1/${ip}/" ${dns_conffile}sed -i '$a mail IN A '"${ip}" ${dns_conffile}sed -i '$a '"${domain}. IN MX 10 mail.${domain}." ${dns_conffile}systemctl restart named.serviceif [ $? -ne 0 ]thenecho '启动named失败'exitfi#解决SMTP服务问题dnf install postfix -yconf_file='/etc/postfix/main.cf'sed -i '$a '"myhostname = mail.${domain}" ${conf_file}sed -i '$a '"mydomain = ${domain}" ${conf_file}sed -i '$a myorigin = $mydomain' ${conf_file}sed -i '$a inet_interfaces = all' ${conf_file}sed -i '$a mydestination = $myhostname, $mydomain, localhost' ${conf_file}systemctl restart postfix.serviceif [ $? -ne 0 ]thenecho '启动postfix失败'exitfi#配置并启动Apachednf install httpd -ysystemctl start httpd.service#安装配置OpenWebMail#Install "Development Tools" group if not installeddnf groupinstall 'Development Tools' -y#Configure openwebmail repository for EL8dnf install yum-utils -yyum-config-manager --add-repo https://openwebmail.org/repo/el8/openwebmail-el8.repo#Install openwebmail pkgs for EL8yum install openwebmail -y#Run openwebmail-tool to initialize/usr/local/bin/openwebmail-tool --init/usr/local/bin/openwebmail-tool --fix#浏览器访问测试#http://服务器地址/webmail#完善工作#1.创建初始页cp /var/www/data/openwebmail/redirect.html /var/www/html/index.html#2.更改为中文界面sed -i 's/.*default_language .*/default_language zh_CN.UTF-8/' /var/www/cgi-bin/openwebmail/etc/openwebmail.confsed -i 's/.*default_iconset .*/default_iconset Cool3D.Chinese.Simplified/' /var/www/cgi-bin/openwebmail/etc/openwebmail.conf#3.修改缺省域sed -i 's/.*domainnames .*/domainnames sziit2003010211.cn/' /var/www/cgi-bin/openwebmail/etc/openwebmail.conf#配置相关服务systemctl enable named.servicesystemctl enable postfix.servicesystemctl enable httpd.servicesystemctl restart named.servicesystemctl restart postfix.servicesystemctl restart httpd.service#防火墙配置firewall-cmd --add-service=dns --permanentfirewall-cmd --add-service=smtp --permanentfirewall-cmd --add-service=pop3s --permanentfirewall-cmd --add-service=http --permanentfirewall-cmd --reload#SELinux配置chcon -t httpd_unconfined_script_exec_t /var/www/cgi-bin/openwebmail/openwebmail*.pl
