基于虚拟用户和虚拟域的邮件系统架构

基于虚拟用户和虚拟域的邮件系统架构_第1张图片
20130826114537750.jpg
基于虚拟用户和虚拟域的邮件系统架构_第2张图片
jiy.png

postfix+cyrus-sasl+courier-authlib+dovecot+extmail+extman+mysql

  • 按装postfix
#2.6.6
yum -y intall postfix
#创建个mymail组和用户 id为666 ,之所以创建是因为用自动自带的postfix用户会报错,不知道怎么回事,如果是编译安装的postfix,就不用单独说这个事了。/var/mailbox 要设置成666的权限
#vim /etc/postfix/main.cf
broken_sasl_auth_clients = yes
header_checks = regexp:/etc/postfix/my_header_checks
inet_interfaces = all
inet_protocols = ipv4
mail_owner = postfix
mynetworks = 127.0.0.0/8
#setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = 
smtpd_sasl_path = smtpd
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = cyrus
virtual_alias_domains = 
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:666
virtual_mailbox_base = /var/mailbox
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = virtual
virtual_uid_maps = static:666
================================================
#vim  /etc/postfix/mysql_virtual_alias_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address
additional_conditions = AND active = '1'
===================================================
#vim /etc/postfix/mysql_virtual_domains_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = domain
select_field = domain
where_field = domain
additional_conditions = AND active = '1'
===================================================
#vim  /etc/postfix/mysql_virtual_mailbox_maps.cf
user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username
additional_conditions = AND active = '1'

  • 安装 cyrus-sasl,cyrus-sasl-devel,编译安装courier-authlib(需要courier-什么玩意来着 忘记了)
#vim /etc/sasl2/smtpd.conf
#pwcheck_method: saslauthd
pwcheck_method: authdaemond
log_level: 3
mech_list: plain login
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
=================================
#courier-authlib 编译参数
./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
============================================
#vim /etc/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
daemons=5
authdaemonvar=/usr/local/courier-authlib/var/spool/authdaemon
DEBUG_LOGIN=2
DEFAULTOPTIONS=""
LOGGEROPTS=""

=====================================
#vim /etc/authmysqlrc
MYSQL_SERVER        localhost
MYSQL_USERNAME      extmail
MYSQL_PASSWORD      extmail
MYSQL_SOCKET   /var/lib/mysql/mysql.sock
MYSQL_PORT  3306
MYSQL_OPT       0
MYSQL_DATABASE      extmail
MYSQL_USER_TABLE    mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD     89
MYSQL_GID_FIELD     89
MYSQL_LOGIN_FIELD   username
MYSQL_HOME_FIELD    concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD    name
 MYSQL_MAILDIR_FIELD    concat('/var/mailbox/',maildir)

=================================================


  • yum安装dovecot
#doveconf -n
# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-696.16.1.el6.x86_64 x86_64 CentOS release 6.8 (Final) ext4
disable_plaintext_auth = no
mail_location = maildir:/var/mailbox/%d/%n/Maildir
mbox_write_locks = fcntl
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocols = imap pop3
ssl_cert = 
  • 安装extmail和extman,其实这个可以在第一步执行,因为需要这个提供的自动建库脚本,和postfix用的mysql脚本
#/var/www/extsuite/extmail
#/var/www/extsuite/extman
sed -i 's/extmail.org/test.com/g' /var/www/extsuite/extman/docs/init.sql
sed -i 's/1000/666/g' /var/www/extsuite/extman/docs/init.sql
mysql -u root -p 
    ServerAdmin [email protected]
    DocumentRoot /var/www/extsuite
    ServerName mail.flylong.top
   ServerAlias mail.xiuxiumail.top
    ErrorLog logs/xiuxiumail-error_log
    CustomLog logs/xiuxiu-access_log common
    ScriptAlias /extmail/cgi  /var/www/extsuite/extmail/cgi
    ScriptAlias /extman/cgi  /var/www/extsuite/extman/cgi
    Alias /extmail /var/www/extsuite/extmail/html
    Alias /extman /var/www/extsuite/extman/html
#如果这里不用suexec的话 要修改 user 和 group配置项
#    SuexecUserGroup postfix postfix
    
    AllowOverride None
    Options ExecCGI 
    Order allow,deny
    Allow from all
 


你可能感兴趣的:(基于虚拟用户和虚拟域的邮件系统架构)