邮件服务系列-- postifx+sasl+dovecot+webmail+webmain架构
[root@localhost ~]# yum groupinstall "Development Tools" "Development Libraries" –y
#yum install httpd openssl-devel perl-DBD-MySQL, tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect(主机间通信)
1. [root@localhost ~]# yum install httpd -y
3. [root@localhost ~]# rpm -e bind-utils bind-libs
4. [root@localhost ~]# yum install bind97 bind97-libs bind97-utils –y
9. directory "/var/named";
10. dump-file "/var/named/data/cache_dump.db";
11. statistics-file "/var/named/data/named_stats.txt";
12. memstatistics-file "/var/named/data/named_mem_stats.txt";
13. recursion yes;
16. /* Path to ISC DLV key */
17. bindkeys-file "/etc/named.iscdlv.key";
21.zone "doubao.com" {
22. type master;
23. file "doubao.com.zone";
24. };
25.zone "111.16.172.in-addr.arpa" {
26. type master;
27. file "172.16.111.zone";
28. };
2. [root@localhost ~]# vim /var/named/doubao.com.zone
5. @ IN SOA ns.doubao.com. admin.doubao.com. (
6. 2013042801
7. 2H
8. 5M
9. 3D
10. 7D )
11. IN NS ns
12. IN MX 10 mail
13.ns IN A 172.16.111.3
14.mail IN A 172.16.111.3
15.www IN A 172.16.111.3
19.[root@localhost ~]# vim /var/named/172.16.111.zone
23. IN SOA ns.doubao.com. admin.doubao.com. (
24. 2013042801
25. 2H
26. 5M
27. 3D
28. 7D )
29. IN NS ns.doubao.com.
30.3 IN PTR ns.doubao.com.
31.3 IN PTR mail.doubao.com.
32.3 IN PTR www.doubao.com.
1. [root@localhost named]# chgrp named doubao.com.zone
2. [root@localhost named]# chgrp named 172.16.111.zone
3. [root@localhost named]# chmod 640 doubao.com.zone
4. [root@localhost named]# chmod 640 172.16.111.zone
5. [root@localhost named]# chkconfig --add named
6. [root@localhost named]# chkconfig named on
7. [root@localhost named]# chkconfig --list named
8. named 0:off 1:off 2:on 3:on 4:on 5:on 6:off
1. [root@localhost named]# vim /etc/resolv.conf
1. [root@localhost named]# vim /etc/sysconfig/network
8. [root@localhost named]# vim /etc/hosts
9. [root@localhost named]# hostname mail.doubao.com
10.[root@localhost named]# hostname
13.[root@mail httpd]# vim /etc/hosts
14.172.16.111.3 mail.doubao.com
16.[root@mail httpd]# service httpd start
17.Starting httpd: [ OK ]
18.[root@mail httpd]# service named restart
19.Starting named: [ OK ]
22. 文件路径:C盘àWindowsàSystem32àdriversàetcàhosts
23. 172.16.111.3 mail.doubao.com
1. [root@mail httpd]# yum install perl-DBD-MySQL
3. [root@mail httpd]# yum install mysql-server mysql-devel –y
6. [root@mail httpd]# service mysqld start
1. [root@mail httpd]# service sendmail stop
2. Shutting down sm-client: [ OK ]
3. Shutting down sendmail: [ OK ]
4. [root@mail httpd]# chkconfig sendmail off
1. [root@mail httpd]# groupadd -g 2525 postfix
2. [root@mail httpd]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
3. [root@mail httpd]# groupadd -g 2526 postdrop
4. [root@mail httpd]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
3. [root@mail ~]# cd /usr/local/src
4. [root@mail src]# tar xf postfix-2.9.6.tar.gz
5. [root@mail src]# 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'
6. [root@mail src]# make && make install
24.[root@mail src]# newaliases
1. [root@mail src]# vim /etc/rc.d/init.d/postfix
5. # postfix Postfix Mail Transfer Agent
7. # chkconfig: 2345 80 30
8. # description: Postfix is a Mail Transport Agent, which is the program \
9. # that moves mail from one machine to another.
11.# pidfile: /var/spool/postfix/pid/master.pid
12.# config: /etc/postfix/main.cf
13.# config: /etc/postfix/master.cf
15.# Source function library.
18.# Source networking configuration.
21.# Check that networking is up.
22.[ $NETWORKING = "no" ] && exit 3
24.[ -x /usr/sbin/postfix ] || exit 4
25.[ -d /etc/postfix ] || exit 5
26.[ -d /var/spool/postfix ] || exit 6
32. # Start daemons.
33. echo -n $"Starting postfix: "
35. /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog
38. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
39. echo
40. return $RETVAL
45. echo -n $"Shutting down postfix: "
46. /usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog
49. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
50. echo
51. return $RETVAL
55. echo -n $"Reloading postfix: "
56. /usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog
59. echo
60. return $RETVAL
64. /usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog
66. return $?
70. /usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog
72. return $?
76. /usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog
78. return $?
82. stop
83. start
86.# See how we were called.
89. start
90. ;;
92. stop
93. ;;
95. stop
96. start
97. ;;
99. reload
100. ;;
101. abort)
102. abort
103. ;;
104. flush)
105. flush
106. ;;
107. check)
108. check
109. ;;
110. status)
111. status master
112. ;;
113. condrestart)
114. [ -f /var/lock/subsys/postfix ] && restart || :
115. ;;
116. *)
117. echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|
118. condrestart}"
119. exit 1
120. esac
121.
122. exit $?
123.
124. # END
1. [root@mail src]# chmod +x /etc/rc.d/init.d/postfix
2. [root@mail src]# chkconfig --add postfix
3. [root@mail src]# chkconfig postfix on
1. [root@mail src]# service postfix start
2. Starting postfix: [ OK ]
1. [root@mail src]# useradd hadoop && echo "hadoop" |passwd --stdin hadoop
1. [root@mail src]# telnet mail.doubao.com 25
1. [root@mail ~]# yum install dovecot -y
3. [root@mail ~]# vim /etc/dovecot.conf
5. [root@mail ~]# chkconfig --add dovecot
6. [root@mail ~]# chkconfig dovecot on
7. [root@mail ~]# chkconfig --list dovecot
8. dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
9. [root@mail ~]# service dovecot start
11.[root@mail ~]# telnet mail.doubao.com 25
1. [root@mail ~]# vim /etc/sysconfig/saslauthd
6. [root@mail ~]# chkconfig --add saslauthd
7. [root@mail ~]# chkconfig saslauthd on
8. [root@mail ~]# chkconfig --list saslauthd
9. saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
10.[root@mail ~]# service saslauthd start
11.Starting saslauthd: [ OK ]
13.[root@mail ~]# testsaslauthd -uhadoop -phadoop
14.0: OK "Success."
1. [root@mail ~]# vim /usr/lib/sasl2/smtpd.conf
1. [root@mail ~]# vim /etc/postfix/main.cf
3. ############################CYRUS-SASL############################
5. smtpd_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_destination
10.smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
1. [root@mail ~]# /usr/sbin/postfix reload
2. postfix/postfix-script: refreshing the Postfix mail system
1. [root@mail ~]# tar xf courier-authlib-0.64.0.tar.bz2
2. [root@mail ~]# cd courier-authlib-0.64.0
3. [root@mail courier-authlib-0.64.0]# ./configure \
6. --without-authpam \
7. --without-authshadow \
8. --without-authvchkpw \
20.[root@mail courier-authlib-0.64.0]# make && make install
1. [root@mail ~]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
1. [root@mail ~]# cp /etc/authdaemonrc.dist /etc/authdaemonrc
2. [root@mail ~]# cp /etc/authmysqlrc.dist /etc/authmysqlrc
1. [root@mail ~]# vim /etc/authdaemonrc
7. MYSQL_SOCKET /var/lib/mysql/mysql.sock
16.MYSQL_MAILDIR_FIELD concat('/var/mailbox/',maildir)
2. [root@mail ~]# cd courier-authlib-0.64.0
3. [root@mail courier-authlib-0.64.0]# cp courier-authlib.sysvinit /etc/rc.d/init.d/courier-authlib
4. [root@mail courier-authlib-0.64.0]# chmod 755 /etc/init.d/courier-authlib
5. [root@mail courier-authlib-0.64.0]# chkconfig --add courier-authlib
6. [root@mail courier-authlib-0.64.0]# chkconfig --level 2345 courier-authlib on
7. [root@mail courier-authlib-0.64.0]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
8. [root@mail courier-authlib-0.64.0]# service courier-authlib start
9. Starting Courier authentication services: authdaemond
1. [root@mail ~]# mkdir –pv /var/mailbox
2. [root@mail ~]# chown -R postfix /var/mailbox
接下来重新配置SMTP 认证,编辑 /usr/lib/sasl2/smtpd.conf ,
1. [root@mail ~]# vim /usr/lib/sasl2/smtpd.conf
6. authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
1. [root@mail ~]# vim /etc/postfix/main.cf
3. ########################Virtual Mailbox Settings########################
5. virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
6. virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
8. virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
14.##########################QUOTA Settings########################
19.virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
21.virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.
2. [root@mail ~]# cd extman-1.1/docs/
7. [root@mail docs]# cp mysql* /etc/postfix/
10.Welcome to the MySQL monitor. Commands end with ; or \g.
11.Your MySQL connection id is 5
12.Server version: 5.0.77 Source distribution
14.Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
16.mysql> GRANT all privileges on extmail.* TO extmail@localhost IDENTIFIED BY 'extmail';
17.Query OK, 0 rows affected (0.00 sec)
19.mysql> GRANT all privileges on extmail.* TO [email protected] IDENTIFIED BY 'extmail';
20.Query OK, 0 rows affected (0.00 sec)
1、启用虚拟域以后,需要取消中心域,即注释掉myhostname, mydestination, mydomain, myorigin几个指令;当然,你也可以把mydestionation的值改为你自己需要的。
# sed -i 's@TYPE=MyISAM@ENGINE=InnoDB@g' extmail.sql
1. [root@mail ~]# vim /etc/dovecot.conf
6. passdb sql {
9. userdb sql {
14.[root@mail ~]# vim /etc/dovecot-mysql.conf
15.##添加如下内容
connect = host=/tmp/mysql.sock dbname=extmail user=extmail password=extmail
1. [root@mail ~]# service dovecot restart
2. Stopping Dovecot Imap: [ OK ]
3. Starting Dovecot Imap: [ OK ]
1. [root@mail ~]# tar xf extmail-1.2.tar.gz
2. [root@mail ~ ]# mkdir -pv /var/www/extsuite
3. mkdir: created directory `/var/www/extsuite'
4. [root@mail ~]# mv extmail-1.2 /var/www/extsuite/extmail
5. [root@mail ~]# cp /var/www/extsuite/extmail/webmail.cf.default /var/www/extsuite/extmail/webmail.cf
1. [root@mail ~]# vim /var/www/extsuite/extmail/webmail.cf
24.SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
26.SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
2. #DocumentRoot "/var/www/html"
6. DocumentRoot /var/www/extsuite/extmail/html/
7. ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
8. Alias /extmail /var/www/extsuite/extmail/html
13.[root@mail ~]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/
15.[root@mail ~]# vim /etc/httpd/httpd.conf
19.[root@mail ~]# vim /etc/httpd/conf/httpd.conf
23.DocumentRoot /var/www/extsuite/extmail/html/
24.ScriptAlias /extmail/cgi /var/www/extsuite/extmail/cgi
25.Alias /extmail /var/www/extsuite/extmail/html
1. [root@mail ~]# tar zxvf Unix-Syslog-1.1.tar.gz
2. [root@mail ~]# cd Unix-Syslog-1.1
3. [root@mail Unix-Syslog-1.1]# perl Makefile.PL
4. [root@mail Unix-Syslog-1.1]# make && make install
1. [root@mail Unix-Syslog-1.1]# service httpd restart
2. Stopping httpd: [ OK ]
3. Starting httpd: [ OK ]
2. mysql> GRANT ALL PRIVILEGES ON extmail.* TO webman@localhost IDENTIFIED BY 'webman';
3. mysql> GRANT ALL PRIVILEGES ON extmail.* TO [email protected] IDENTIFIED BY 'webman';
5. [root@mail ~]# mv extman-1.1 /var/www/extsuite/extman
6. [root@mail ~]# cd /var/www/extsuite/extman/
7. [root@mail extman]# cp /var/www/extsuite/extman/webman.cf.default /var/www/extsuite/extman/webman.cf
1. [root@mail extman]# vim /var/www/extsuite/extman/webman.cf
1. [root@mail extman]# mkdir /tmp/extman
2. [root@mail extman]# chown postfix.postfix /tmp/extman
1. ScriptAlias /extmail/cgi /var/www/extsuite/extman/cgi
2. Alias /extman /var/www/extsuite/extmail/html
1. [root@mail extman]# vim /etc/httpd/conf/httpd.conf
2. [root@mail extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi
1. [root@mail extman]# service httpd restart