linux运维-postfix+mysql

mysql+postfix
    yum install httpd php php-mysqlmariadb-server -y
linux运维-postfix+mysql
    vim /etc/my.conf
    skip-networking=1   ##关闭通过网络登陆

linux运维-postfix+mysql
    systemctl restart mariadb
    解压php-admin到
/var/www/html
    cd /var/www/html
    cp -p config.sample.inc.phpconfig.inc.php
    mysql_secure_installition   ##数据库安全初始化

    172.5.254.222/myadmin       ##进入网页管理数据库
    新建email数据库,新建emailuser表
    子段: username  password    domain    mailbox
       [email protected]   linux    123.com    /123.com/linux
linux运维-postfix+mysql


linux运维-postfix+mysql   

mysql -uroot -pwestos
    create user [email protected] by 'postuser';
    grant select,update,insert on email.*to [email protected];
linux运维-postfix+mysql
    vim /etc/postfix/main.cf /mnt/
    vim /etc/postfix/mailuser.cf    ##用户主机名称查询

    host = loscalhost       ##数据库所在主机名
    user = postuser         ##登陆数据库的用户
    password = postuser     ##登陆数据库的密码
    dbname = email          ##postfix要查询库的名称
    table = emiluser        ##postfix要查询表的名称
    select_field = username     ##postfix要查询的子段
    where_field = username      ##用户给定postfix的查询条件
linux运维-postfix+mysql
    vim /etc/postfix/maildomain.cf  ##用户邮箱域名查询

    hosts = localhost
    user = postuser
    password = postuser
    dbname = email
    table = emiluser
    select_field = domain
    where_field = domain
linux运维-postfix+mysql
    vim /etc/postfix/mailbox.cf ##用户邮箱查询

    hosts = localhost
    user = postuser
    password = postuser
    dbname = email
    table = emiluser
    select_field = maildir
    where_field = username
linux运维-postfix+mysql
    postmap -q "[email protected]"mysql:/etc/postfix/mailuser.cf   ##检测用户配置

    postmap -q "123.com"mysql:/etc/postfix/maildomain.cf       ##检测域名配置
    postmap -q "[email protected]"mysql:/etc/postfix/mailbox.cf    ##检测邮箱配置

    groupadd -g 666 vmail   ##
新建vmail组,指定其gid=666
    useradd -s /sbin/nologin -u 666 vmail-g 666 ##新建vmail用户,加入vmail组,设置非交互式登陆

    postconf -e "virtual_mailbox_base= /home/vmail ##设置邮件家目录
    postconf -e "virtual_uid_maps =static:666" ##指定uid
    postconf -e "virtual_gid_maps =static:666" ##指定
gid
    postconf -e "virtual_alias_maps =mysql:/etc/postfix/mailuser.cf"   ##获取邮箱

    postconf -e "virtual_mailbox_maps= mysql:/etc/postfix/mailbox.cf"  ##获取域名
    systemtl restart postfix
   
测试:
    mail [email protected]
    cd /home/vmail ##
可以看到邮件