虚拟账号的文件系统extmail 上
基于虚拟账号的邮件系统extmail的实现一.实现DNS的正常解析1.基本的配置略:如要改主机名,dns的安装(bind bind-chroot caching-nameserver),dns指向和配置,效果测试图如下2.查看邮件交换器是否正常工作。
二.安装前的准备工作如下1、安装所需的rpm包,这包括以下这些:Httpd(web访问界面用到), php, php-mysql(php和mysql的连接器件), mysql(mysql工具), mysql-server(数据库服务器), mysql-devel(头文件库文件), openssl-devel, dovecot(邮件接收服务器), perl-DBD-MySQL, tcl, tcl-devel, libart_lgpl, libart_lgpl-devel, libtool-ltdl, libtool-ltdl-devel, expect(后面都是被依赖的软件包)# yum install httpd php php-mysql mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect2、安装以下开发所用到的rpm包组:(源代码安装时都要用到)Development Libraries(开发库)Development Tools (开发工具)Legacy Software Development(老的软件开发)X Software Development(x的软件开发)# yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software Development"(注意要用引号)3、启动mysql数据库,并给mysql的root用户设置密码:# service mysqld start# chkconfig mysqld on 方法一:mysqladmin -u root password 'your_password'(基本的密码设置)方法二:先进入mysql数据库mysql> SETPASSWORD FOR root@'localhost'=PASSWORD('redhat');Query OK, 0 rows affected (0.00 sec)mysql> SETPASSWORD FOR root@'127.0.0.1'=PASSWORD('redhat');(设置本密码)Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES;(刷新使设置生效)Query OK, 0 rows affected (0.00 sec)mysql> GRANTALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'redhat';(设置管理员远程登录密码)Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec)# mysql -u root -p (设完密码可以这样进入数据库)4、启动saslauthd服务,并将其加入到自动启动队列# service saslauthd statussaslauthd 已停# service saslauthd start启动 saslauthd: [确定# chkconfig --list saslauthdsaslauthd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭# chkconfig saslauthd on二、几个软件源代码的安装1、解压并创建用户及组# tar -zxvf postfix-2.8.2.tar.gz -C /usr/local/src/# groupadd -g 2525 postfixgroupadd:postfix 组已存在 (这样是不对的,要改的不出现这个提示)# vim /etc/passwd# userdel -r postfix# useradd -g postfix -u 2525 -s /sbin/nologin -M postfixuseradd:用户 postfix 已存在# vim /etc/group# userdel -r postdrop# groupadd -g 2526 postdropgroupadd:postdrop 组已存在#useradd -g postdrop -u 2526 -s /bin/false -M postdrop2、这个没有./configure文件,编译可执行文件# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl-DUSE_TLS ' 'AUXLIBS=-L/usr/lib/mysql -lmysqlclient -lz -lm -L/usr/lib/sasl2 -lsasl2 -lssl -lcrypto'# make # make install3、生成别名二进制文件,这个步骤如果忽略,会造成postfix效率极低:# newaliases# postfix start# postconf -m(查看支持的模块)可以看到已经支持mysql了如果是rpm安装的不支持mysql# postconf -a Cyrus(可以看到支持验证)Dovecot4、刚重启是用postfix start 而不支持service ,需要改写控制脚本,# mkdir /tmp/hua# cd /tmp/hua/# ll总计 0# cp /mnt/cdrom/Server/postfix-2.3.3-2.1.el5_2.i386.rpm ./# rpm2cpio postfix-2.3.3-2.1.el5_2.i386.rpm |cpio -id (rpm包展开)进入这个目录下:# pwd/tmp/hua/etc/rc.d/init.d# cp postfix /etc/init.d/现在就可以用service 控制了。# chkconfig --add postfix(添加控制)# chkconfig --list postfixpostfix 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭# chkconfig postfix on检查postfix是否正常,正常
5、编辑住配置文档# vim /etc/postfix/main.cf修改以下几项为您需要的配置myhostname = mail.a.orgmydomain =a.orgmydestination = $myhostname, localhost.$mydomain, localhost, $mydomainmynetworks = 192.168.1.0/24, 127.0.0.0/8各参数的介绍:myorigin参数用来指明发件人所在的域名;mydestination参数指定postfix接收邮件时收件人的域名,即您的postfix系统要接收到哪个域名的邮件;myhostname 参数指定运行postfix邮件系统的主机的主机名,默认情况下,其值被设定为本地机器名;mydomain参数指定您的域名,默认情况下,postfix将myhostname的第一部分删除而作为mydomain的值;mynetworks 参数指定你所在的网络的网络地址,postfix系统根据其值来区别用户是远程的还是本地的,如果是本地网络用户则允许其访问;inet_interfaces 参数指定postfix系统监听的网络接口;三、、为postfix开启基于cyrus-sasl的认证功能使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:# postconf -a Cyrus(可以看到支持验证)Dovecot1、vi /etc/postfix/main.cf输入大写G到最后一行添加以下内容:############################CYRUS-SASL############################broken_sasl_auth_clients = yessmtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_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 = yessmtpd_sasl_local_domain = $myhostnamesmtpd_sasl_security_options = noanonymoussmtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!(可不添加)2、要实现验证要做下面的东西# cd /usr/lib/sasl2/# cp -p Sendmail.conf smtpd.conf# vim smtpd.conf 添加内容是:mech_list: PLAIN LOGIN# service saslauthd restart查看一下,已经支持验证了
四、安装Courier authentication library1、# tar -jxvf courier-authlib-0.63.0.tar.bz2 -C /usr/local/src/# ./configure --prefix=/usr/local/courier-authlib --sysconfdir=/etc --with-authmysql --with-mysql-libs=/usr/lib/mysql --with-mysql-includes=/usr/include/mysql --with-redhat --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc --with-ltdl-lib=/usr/lib --with-ltdl-include=/usr/includeroot@mail courier-authlib-0.63.0]# make root@mail courier-authlib-0.63.0]# make install2、# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon# cp /etc/authdaemonrc.dist/etc/authdaemonrc# cp /etc/authmysqlrc.dist/etc/authmysqlrc(拷贝两个样例文件成执行的脚本文件)3、# vim /etc/authdaemonrc (修改使其能经过mysql的验证)修改的:authmodulelist="authmysql"authmodulelistorig="authmysql"daemons=104、# vim /etc/authmysqlrc要修改的:编辑/etc/authmysqlrc 为以下内容,其中2525,2525 为postfix 用户的UID和GID。MYSQL_SERVER localhostMYSQL_PORT 3306 (指定你的mysql监听的端口,这里使用默认的3306)MYSQL_USERNAMEextmail (这时为后文要用的数据库的所有者的用户名)MYSQL_PASSWORD extmail (密码)MYSQL_SOCKET/var/lib/mysql/mysql.sockMYSQL_DATABASEextmailMYSQL_USER_TABLEmailboxMYSQL_CRYPT_PWFIELDpasswordMYSQL_UID_FIELD'2525'MYSQL_GID_FIELD'2525'MYSQL_LOGIN_FIELDusernameMYSQL_HOME_FIELDconcat('/var/mailbox/',homedir)MYSQL_NAME_FIELDnameMYSQL_MAILDIR_FIELDconcat('/var/mailbox/',maildir)5.Courier authentication library 作为一个服务,要受到service的控制# cp -p courier-authlib.sysvinit /etc/init.d/courier-authlib因为一个服务的控制脚本应该有可执行权限,所以要改权限#chmod 755 /etc/init.d/courier-authlib# service courier-authlib startStarting Courier authentication services: authdaemond# chkconfig --add courier-authlib # chkconfig --list courier-authlibcourier-authlib 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭# chkconfig courier-authlib on6、因为头文件和库文件都不是规定的,还需要修改头文件库文件# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf# ldconfig -pv |grep cour 新建虚拟用户邮箱所在的目录,并将其权限赋予postfix用户:# mkdir -pv /var/mailbox# chown -R postfix /var/mailbox# ll -d /var/mailbox/drwxr-xr-x 2 postfix root 4096 12-16 13:36 /var/mailbox/ (用户的所有组已经是postfix了)7、接下来重新配置SMTP 认证,编辑 /usr/lib/sasl2/smtpd.conf ,确保其为以下内容:pwcheck_method: authdaemondlog_level: 3mech_list:PLAIN LOGINauthdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket:.!ls -l /usr/local/courier-authlib/var/spool/authdaemon/socket(此命令可以查看输入的目录是否存在)# service courier-authlib restart五、让postfix支持虚拟域和虚拟用户1、编辑/etc/postfix/main.cf,添加如下内容:########################Virtual Mailbox Settings########################virtual_mailbox_base = /var/mailboxvirtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cfvirtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cfvirtual_alias_domains =virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cfvirtual_uid_maps = static:2525virtual_gid_maps = static:2525virtual_transport = virtualmaildrop_destination_recipient_limit = 1maildrop_destination_concurrency_limit = 1##########################QUOTA Settings########################message_size_limit = 14336000virtual_mailbox_limit = 20971520virtual_create_maildirsize = yesvirtual_mailbox_extended = yesvirtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cfvirtual_mailbox_limit_override = yesvirtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.virtual_overquota_bounce = yes2、使用extman(提供在线管理)源码目录下docs目录中的extmail.sql和init.sql建立数据库:只需要进行解压包导入数据库即可,不需要在进行安装了。# tar -zxvf extman-1.1.tar.gz # cd docs/# mysql -u root -p <extmail.sqlEnter password: # mysql -u root -p <init.sqlEnter password: 进入数据库查看
3、# cp mysql_virtual_* /etc/postfix/ 4、授予用户extmail访问extmail数据库的权限先进入数据库mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';mysql> GRANT all privileges on extmail.* TO extmail@127.0.0.1 IDENTIFIED BY 'extmail';mysql>FLUSH PRIVILEGES; 让设置的内容生效servicepostfixrestart说明:启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。 昨天,系花对我笑了一下,乐得我晚上直数羊,一只羊,两只羊,三只羊…… 流氓不可怕,就怕流氓有文化。 做爱做的事,交配交的人。 老天,你让夏天和冬天同房了吧?生出这鬼天气! 怀揣两块,胸怀500万! 天塌下来你顶着,我垫着!
页:
[1]