一、邮件服务架构

bind:域名解析
postfix:实现SMTP协议,用于发件
dovecot:实现POP3和IMAP协议,用于收件
Cyrus-SASL函数库:用于用户认证
courier-authlib:使用MySQL数据库中的表进行身份验证
extmail和extman:提供webmail

在这里插入图片描述
二、部署bind
2.1、yum安装

yum -y install bind bind-utils

2.2、配置bind
主配置文件

vim /etc/named.conf 
        //listen-on port 53 { 127.0.0.1; };
        //listen-on-v6 port 53 { ::1; };
       //allow-query     { localhost; };

直接注释listen与allow-query,就可以监听在所有地址上并且允许所有主机访问

定义正反向区域配置文件

vim /etc/named.rfc1912.zones
zone "zhongdianjizhi.com" IN {
        type master;
        file "zhongdianjizhi.com.zone";
};      
zone "118.168.192.in-addr.arpa" {
        type master;
        file "zhongdianjizhi.com.local";
}; 

定义区域解析库文件(配置A记录与MX记录)

cd /var/named
cp -p named.localhost zhongdianjizhi.com.zone
cp -p named.localhost zhongdianjizhi.com.local 
vim /var/named/zhongdianjizhi.com.zone
$TTL 86400
@       IN SOA   ns.zhongdianjizhi.com. admin.zhongdianjizhi.com. (
                                        201902  ; serial
                                        2H      ; refresh
                                        10M      ; retry
                                        3D      ; expire
                                        1D )    ; minimum
        IN      NS       ns
        IN      MX 10    mail
ns       IN   A       192.168.118.100
mail     IN   A       192.168.118.100
vim /var/named/zhongdianjizhi.com.local
$TTL 86400
@       IN SOA   ns.zhongdianjizhi.com. admin.zhongdianjizhi.com. (
                                        201902  ; serial
                                        2H      ; refresh
                                        10M      ; retry
                                        3D      ; expire
                                        1D )    ; minimum
 
        IN      NS       ns.zhongdianjizhi.com.
1        IN      PTR      ns.zhongdianjizhi.com.
1        IN      PTR      mail.zhongdianjizhi.com.

2.3、检查配置文件是否有语法错误

named-checkzone "zhongdianjizhi.com.zone" /var/named/zhongdianjizhi.com.zone
named-checkzone "118.168.192.in-addr.arpa" /var/named/zhongdianjizhi.com.local 

2.4、修改区域解析库文件权限与属组

chgrp named /var/named/zhongdianjizhi.com.*
chmod 640 /var/named/zhongdianjizhi.com.*

2.5、将本机dns解析指向本机dns服务器

vim /etc/resolv.conf 
nameserver 192.168.118.100

2.6、修改主机名

hostnamectl set-hostname mail.zhongdianjizhi.com

2.7、启动named服务(bind是包名,服务名为named)

systemctl start named
systemctl enable named

2.8、测试解析

dig -t A mail.zhongdianjizhi.com @192.168.118.100
dig -x 192.168.118.100 @192.168.118.100

三、编译安装postfix
3.1、准备
移除系统自带的postfix

rpm -e postfix

删除postfix用户

userdel postfix
groupdel postdrop

新建用户

groupadd -g 2525 postfix
useradd -g 2525 -u 2525 -M -s /sbin/nologin postfix
groupadd -g 2526 postdrop
useradd -g 2526 -u 2526 -M -s /sbin/nologin postdrop

3.2下载postfix源码包,目前的稳定版为3.4版本

wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/official/postfix-3.4.5.tar.gz

3.3、安装mariadb

yum -y install mariadb-server mariadb-devel 
systemctl start mariadb.service 

3.4、安装编译环境及其他所需包

yum -y install gcc gcc-c++ make pcre-devel expat-devel perl
yum -y install   openssl openssl-devel db4-devel ntpdate  bzip2 php-mysql cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel libtool-ltdl-devel telnet mail libicu-devel m4 expect httpd

3.5、找到mysql与sasl的头文件以及库文件安装位置

rpm -ql mariadb-devel
Mysql include:/usr/include/mysql
Mysql lib:/usr/lib64/mysql
 
rpm -ql cyrus-sasl-devel
Sasl lib:/usr/lib64/sasl2
Sasl include:/usr/include/sasl

3.6、准备编译

cd /usr/local/src/; tar -xf postfix-3.4.5.tar.gz
cd postfix-3.4.5/

#编译时指定上一步找到的头文件以及库文件位置

make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2   -lssl -lcrypto'
make && make install

在make install过程中交互式的填写配置文件

Please specify the prefix for installed file names. Specify this ONLY
if you are building ready-to-install packages for distribution to OTHER
machines. See PACKAGE_README for instructions.
install_root: [/] 
Please specify a directory for scratch files while installing Postfix. You
must have write permission in this directory.
tempdir: [/usr/local/src/postfix-3.0.11] /tmp/extmail     #更改tmp目录,其他的全部默认
Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix] 
Please specify the final destination directory for installed Postfix
administrative commands. This directory should be in the command search
path of adminstrative users.
command_directory: [/usr/sbin] 
Please specify the final destination directory for installed Postfix
daemon programs. This directory should not be in the command search path
of any users.
daemon_directory: [/usr/libexec/postfix] 
Please specify the final destination directory for Postfix-writable
data files such as caches or random numbers. This directory should not
be shared with non-Postfix software.
data_directory: [/var/lib/postfix] 
Please specify the final destination directory for the Postfix HTML
files. Specify "no" if you do not want to install these files.
html_directory: [no] 
Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix] 
Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq] 
Please specify the final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man] 
Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases] 
Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix] 
Please specify the final destination directory for the Postfix README
files. Specify "no" if you do not want to install these files.
readme_directory: [no]
Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail] 
Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is
not shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop] 
Please specify the final destination directory for Postfix shared-library
files.
shlib_directory: [no]

3.7、配置postfix

主配置文件:/etc/postfix/main.cf
maildrop配置文件:/etc/postfix/master.cf 可通过postconf -e修改

备份
cp /etc/postfix/main.cf{,.bak}
配置文件main.cf
#第94行 修改邮局主机名
myhostname = mail.zhongdianjizhi.com
#第102行 修改邮局域名
mydomain = zhongdianjizhi.com
#第118行 寄出邮件域名,删除注释
myorigin = $mydomain
#第132行 修改监听所有网卡,删除注释
inet_interfaces = all
#第180行 修改可接收邮件的主机名和域名,可被中继的域名
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#第279 修改可接收邮件的主机名和域名,可被中继的主机
mynetworks = 192.168.118.0/24, 127.0.0.0/8
#第434行,取消注释
home_mailbox = Maildir/
#第676行 开启同时使用ipv4和ipv6协议,定义postfix进程监听的IP地址
inet_protocols = all
#第266行 指定信任网段类型
mynetworks_style = host   
#第311行 指定允许中转邮件的域名,取消注释
relay_domains = $mydestination      
#第401行,设置邮件的别名映射表,取消注释
alias_maps = hash:/etc/aliases       
配置结束后使用postconf -n查看配置并核对

3.8、配置服务启动脚本

vim /etc/init.d/postfix
#!/bin/bash
#
# postfix      Postfix Mail Transfer Agent
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program \
#              that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/master.cf
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ $NETWORKING = "no" ] && exit 3
[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6
RETVAL=0
prog="postfix"
start() {
     # Start daemons.
     echo -n $"Starting postfix: "
        /usr/bin/newaliases >/dev/null 2>&1
     /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
     RETVAL=$?
     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
        echo
     return $RETVAL
}
stop() {
  # Stop daemons.
     echo -n $"Shutting down postfix: "
     /usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
     RETVAL=$?
     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
     echo
     return $RETVAL
}
reload() {
     echo -n $"Reloading postfix: "
     /usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
     RETVAL=$?
     echo
     return $RETVAL
}
abort() {
     /usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
     return $?
}
flush() {
     /usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
     return $?
}
check() {
     /usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
     return $?
}
restart() {
     stop
     start
}
# See how we were called.
case "$1" in
  start)
     start
     ;;
  stop)
     stop
     ;;
  restart)
     stop
     start
     ;;
  reload)
     reload
     ;;
  abort)
     abort
     ;;
  flush)
     flush
     ;;
  check)
     check
     ;;
  status)
       status master
     ;;
  condrestart)
     [ -f /var/lock/subsys/postfix ] && restart || :
     ;;
  *)
     echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
     exit 1
esac
exit $?

添加权限,并开机启动

chmod +x /etc/init.d/postfix
chkconfig --add postfix
chkconfig postfix on
chown postfix.postfix -R /var/lib/postfix/
chown postfix.postfix /var/spool/ -R

3.9、生成别名

newaliases 
ls /etc/aliases.db 

3.10、启动并测试

useradd jym
systemctl start postfix
[root@mail ~]# telnet mail.zhongdianjizhi.com 25
Trying fe80::4c54:bb23:c6db:6473%ens33...
telnet: connect to address fe80::4c54:bb23:c6db:6473%ens33: Connection refused
Trying 192.168.118.100...
Connected to mail.zhongdianjizhi.com.
Escape character is '^]'.
220 mail.zhongdianjizhi.com ESMTP Postfix
mail from:root@zhongdianjizhi.com
250 2.1.0 Ok
rcpt to:jym@zhongdianjizhi.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
hello,this is test mail.
.
250 2.0.0 Ok: queued as 13259132D75
quit
221 2.0.0 Bye
Connection closed by foreign host.

Note:写完邮件正文需要以.结束
发送成功

[root@mail ~]# tail /var/log/maillog|grep sent
Jul  1 16:29:56 mail postfix/local[8749]: 13259132D75: to=<jym@zhongdianjizhi.com>, relay=local, delay=66, dela
ys=66/0.01/0/0, dsn=2.0.0, status=sent (delivered to maildir)

四、安装dovecot
4.1、yum安装dovecot

yum -y install dovecot dovecot-mysql

依赖包:clucene-core

4.2、配置dovecot

vim /etc/dovecot/dovecot.conf 
#第24行,取消注释
protocols = imap pop3 lmtp
#第30行,取消注释
listen = *, ::
#第33行,取消注释
base_dir = /var/run/dovecot/
vim /etc/dovecot/conf.d/10-mail.conf 
#第30行,取消注释,为dovecot指明邮箱位置
mail_location = maildir:/var/mailbox/%d/%n/Maildir
配置dovecot连接mysql

cp /etc/dovecot/conf.d/auth-sql.conf.ext /etc/dovecot/conf.d/auth-sql.conf
vim /etc/dovecot/conf.d/auth-sql.conf
passdb {
  driver = sql
  # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
  args = /etc/dovecot/dovecot-sql.conf
}
userdb {
  driver = sql
  args = /etc/dovecot/dovecot-sql.conf
}
 
vim /etc/dovecot/dovecot-sql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'

4.3、启动

systemctl start dovecot.service 

4.4、测试收件

echo "111111" | passwd --stdin jym
[root@mail ~]# telnet mail.zhongdianjizhi.com 110
Trying fe80::4c54:bb23:c6db:6473%ens33...
Connected to mail.zhongdianjizhi.com.
Escape character is '^]'.
+OK Dovecot ready.
user jym
+OK
pass 111111
+OK Logged in.
list
+OK 2 messages:
1 506
2 495
.
retr 1
+OK 506 octets
Return-Path: <root@zhongdianjizhi.com>
X-Original-To: jym@zhongdianjizhi.com
Delivered-To: jym@zhongdianjizhi.com
Received: from mail.zhongdianjizhi.com (mail.zhongdianjizhi.com [192.168.118.100])
    by mail.zhongdianjizhi.com (Postfix) with ESMTP id 13259132D75
    for <jym@zhongdianjizhi.com>; Mon,  1 Jul 2019 16:28:51 +0000 (GMT)
Message-Id: <20190701162941.13259132D75@mail.zhongdianjizhi.com>
Date: Mon,  1 Jul 2019 16:28:51 +0000 (GMT)
From: root@zhongdianjizhi.com
 
hello,this is test mail.

五、sasl配置
配置文件:/etc/sysconfig/saslauthd

5.1、启动

systemctl start saslauthd.service 
systemctl enable saslauthd.service 

5.2、测试

testsaslauthd -ujym -p111111

5.3、smtpd配置

vim /usr/lib64/sasl2/smtpd.conf 
创建smtpd.conf配置文件并写入
log_level: 3  #生产环境关闭,现用于测试
pwcheck_method: authdaemond
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket #authlib的socket路径

5.4、postfix关于smtp的配置

vim /etc/postfix/main.cf
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqd
n_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destinationsmtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_path = smtpd

六、编译安装courier-authlib

postfix使用courier-authlib实现虚拟用户的认证
下载地址:http://www.courier-mta.org/download.html

6.1、编译安装courier-unicode

wget https://sourceforge.net/projects/courier/files/courier-unicode/2.1/courier-unicode-2.1.tar.bz2
tar xf courier-unicode-2.1.tar.bz2
cd courier-unicode-2.1/
./configure 
make && make install

6.2、编译安装courier-authlib

wget https://sourceforge.net/projects/courier/files/authlib/0.69.0/courier-authlib-0.69.0.tar.bz2
tar xf courier-authlib-0.69.0.tar.bz2
cd courier-authlib-0.69.0/
#在编译选项中指定mysql认证,指明mysql的库文件,头文件位置,指明安装目录以及配置文件目录
./configure --prefix=/usr/local/courier-authlib     --sysconfdir=/etc     --without-authpam     --without-authshadow     --without-authvchkpw     --without-authpgsql     --with-authmysql     --with-mysql-libs=/usr/lib64/mysql     --with-mysql-includes=/usr/include/mysql     --with-redhat     --with-authmysqlrc=/etc/authmysqlrc     --with-authdaemonrc=/etc/authdaemonrc     --with-mailuser=postfix --with-mailgroup=postfix     
 
make && make install

6.3、配置courier-authlib

chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
cp /etc/authdaemonrc.dist  /etc/authdaemonrc
cp /etc/authmysqlrc.dist  /etc/authmysqlrc
配置使用mysql认证
vim /etc/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=10   #并发
配置其通过mysql进行邮件账号认证

vim /etc/authmysqlrc
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail   #使用数据库的所有者的用户名
MYSQL_PASSWORD          extmail  #使用数据库的所有者的密码,生产环境下结合实际情况修改,如要修改,后面一系列都要修改
MYSQL_SOCKET            /var/lib/mysql/mysql.sock   #mysql的socket文件路径,根据mysql的安装方式,路径不同
MYSQL_PORT               3306
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password     #设置用户密码
DEFAULT_DOMAIN          zhongdianjizhi.com    #默认域
MYSQL_UID_FIELD         '2525'        #postfix用户的UID
MYSQL_GID_FIELD         '2525'
MYSQL_LOGIN_FIELD       username  #用户所在的表名,必须是username
MYSQL_HOME_FIELD        concat('/var/mailbox/',homedir)  #用户账号家目录
MYSQL_NAME_FIELD        name   #
MYSQL_MAILDIR_FIELD     concat('/var/mailbox/',maildir) 

6.4、导出authlib的库文件给操作系统

echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
ldconfig

6.5、提供sysv服务脚本

cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
chmod 755 /etc/rc.d/init.d/courier-authlib 

6.6、启动服务

systemctl start courier-authlib.service 
systemctl enable courier-authlib.service 

6.7、新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户

mkdir -pv /var/mailbox
chown -R postfix /var/mailbox/

七、配置postfix支持虚拟域和虚拟用户
7.1、编辑/etc/postfix/main.cf,添加以下内容

#####virtual mailbox settings#####
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf   
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:2525
virtual_gid_maps = static:2525
virtual_transport = virtual
 
#####QUOTA settings#####
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
启用虚拟域后,需要取消中心域,即注释掉myhostname,mydestionation,mydomain,myorigin,或者将mydestionation修改为需要的域。

#第94行 修改邮局主机名
#myhostname = mail.zhongdianjizhi.com
#第102行 修改邮局域名
#mydomain = zhongdianjizhi.com
#第118行 寄出邮件域名,删除注释
#myorigin = $mydomain
#第180行 修改可接收邮件的主机名和域名,可被中继的域名
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#第279 修改为只允许本机
mynetworks = 127.0.0.0/8
Note:以上配置的.cf配置文件都是由extman来提供

7.2、使用extman源码目录下docs目录中的extmail.sql和init.sql建立数据库
进入源码包

tar xf extman-1.1.tar.gz
cd extman-1.1/docs/
启动mariadb

systemctl start mariadb.service
修改extmail.sql 文件(mysql5.1以上版本需修改)

sed -i 's/TYPE/ENGINE/g' extmail.sql 
导入数据库

mysql -uroot  < extmail.sql
mysql -uroot  < init.sql

7.3、授予用户extmail访问extmail数据库的权限

MariaDB [extmail]> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
MariaDB [extmail]> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';

7.4、准备虚拟用户的配置文件

cp mysql_virtual_* /etc/postfix/

7.5、重启postfix

systemctl restart postfix.service

八、安装extmail与extman
8.1、安装extmail到httpd根目录/var/www下

tar xf extmail-1.2.tar.gz 
mkdir -pv /var/www/extsuite
mv extmail-1.2 /var/www/extsuite/extmail
cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf

8.2、修改extmail主配置文件

vim /var/www/extsuite/extmail/webmail.cf
#修改语言为中文
SYS_USER_LANG = zh_CN
#修改用户邮件存放目录
SYS_MAILDIR_BASE = /var/mailbox
#修改链接数据库的用户名密码
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
#修改authdaemo socket文件位置
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

8.3、安装extman到httpd根目录/var/www下

mv extman-1.1/ /var/www/extsuite/extman
cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf

8.4、修改extman主配置文件

vim /var/www/extsuite/extman/webman.cf
#修改用户邮件存放目录
SYS_MAILDIR_BASE = /var/mailbox
#关闭验证模块
SYS_CAPTCHA_ON = 0
#修改ID号
SYS_DEFAULT_UID = 2525
SYS_DEFAULT_GID = 2525
#修改连接数据库的用户名密码
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
#修改存放session的临时目录
SYS_SESS_DIR = /tmp

8.5、创建extman保存session的临时目录

mkdir -pv /tmp/extman
chown -R postfix.postfix /tmp/extman

8.6、验证

[root@mail ~]# /usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail
Authentication succeeded.
 
     Authenticated: postmaster@extmail.org  (uid 2525, gid 2525)
    Home Directory: /var/mailbox/extmail.org/postmaster
           Maildir: /var/mailbox/extmail.org/postmaster/Maildir/
             Quota: (none)
Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
Cleartext Password: extmail
           Options: (none)

九、配置apache
9.1、修改httpd主配置文件

vim /etc/httpd/conf/httpd.conf 
#第119行,注释中心主机
#DocumentRoot "/var/www/html"
#修改用户与组为postfix
User postfix
Group postfix
 
结尾加上虚拟主机配置
<VirtualHost *:80>
ServerName mail.zhongdianjizhi.com
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
Alias /extmail /var/www/extsuite/extmail/html
ScriptAlias /extman/cgi /var/www/extsuite/extman/cgi
Alias /extman /var/www/extsuite/extman/html
</VirtualHost>

9.2、修改cgi目录的属主

chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
chown -R postfix.postfix /var/www/extsuite/extman/cgi/

9.3、配置文件语法检查

httpd -t

9.4、编译安装Unix-Syslog

tar xf Unix-Syslog-1.1.tar.gz 
cd Unix-Syslog-1.1/
perl Makefile.PL 
make && make install

9.5、启动httpd

systemctl start httpd

十、登陆webmail管理
http://127.0.01:9002/extmail
在这里插入图片描述

10.1、邮箱管理–添加域与用户
默认用户名:root@extmail.org
默认密码:extmail123

在这里插入图片描述

https://img-blog.csdnimg.cn/20200112211323849.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Zpc2hfc3R1ZHlfY3Nkbg==,size_16,color_FFFFFF,t_70

10.2、登陆邮箱
在这里插入图片描述

10.3、测试收发邮件
在这里插入图片描述

Note:邮件服务已经搭建成功,也测试了向外网邮箱发送邮件,但是要想接收邮件需购买域名,并解析至邮件服务器。

解决启动Apache遇到的问题Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:8888
1.可能原因:SELinux限制了Apache的端口设置
2.解决办法:

//安装semanage
yum provides /usr/sbin/semanage
yum -y install policycoreutils-python
//查看默认允许的端口
semanage port -l | grep -w http_port_t
// http_port_t  tcp  80, 81, 443, 488, 8008, 8009, 8443, 9000
//使用semanage添加apache侦听的端口
semanage port -a -t http_port_t -p tcp 8888
//启动apache
systemctl start httpd
必须要设置:setenforce 0

参考网址:

https://blog.51cto.com/jiayimeng/2416421

https://www.cnblogs.com/stefango/p/9933255.html

修改模板:https://blog.csdn.net/weixin_34238642/article/details/92482293

原文链接:https://blog.csdn.net/fish_study_csdn/article/details/103945578

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐