Postfix + PostfixAdmin + Mysql 邮箱系统部署

安装 Mysql

安装略,参照 配置文件

安装完成后为 postfix 建库建表后面会用

编译安装 Postfix

先卸载系统自带 Postfix,重新编译安装

make -f Makefile.init makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql' 'AUXLIBS_MYSQL=-L /usr/lib64/mys
ql -lmysqlclient -lz -lm'

需要注意的是卸载 Postfix 会导致同步卸载 crontabs,操作完成后重新装上就可以了。

编译安装 Php:

[root]# ./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-cur
l --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-gd --with-jpeg-dir
[root]# make all install

安装 PostfixAdmin:

下载 PostfixAdmin 后修改 Nginx 配置文件:

server {
    listen   80;
    index index.html index.php;
    server_name x.y.c.com;

    root /var/data/postfix/admin;

    location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }
    location ~ \.php$ {
        root /var/data/postfix/admin;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
    }
}

修改 Postfix 配置文件:

/etc/postfix/main.cf 添加 :

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_mailbox_base = /var/spool/mail
virtual_minimum_uid = 100 
virtual_uid_maps = static:5000 
virtual_gid_maps = static:5000

创建 /etc/postfix/mysql_virtual_mailbox_maps.cf:

user = postfix
password = postfix

dbname = postfix
hosts = 127.0.0.1

query  = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'

创建 /etc/postfix/mysql_virtual_domains_maps.cf:

user = postfix
password = postfix

dbname = postfix
hosts = 127.0.0.1
dbname = postfix

query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'

创建 /etc/postfix/mysql_virtual_alias_maps.cf:

user = postfix
password = postfix

dbname = postfix
hosts = 127.0.0.1
dbname = postfix

table = alias
select_field = goto
where_field = address

创建 /etc/postfix/mysql_virtual_mailbox_limit_maps.cf:

user = postfix
password = postfix

dbname = postfix
hosts = 127.0.0.1
dbname = postfix

query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'

All Done!

启动 postfix 就可以了

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注