实验环境:三台主机,分别为
          mail.zbka.com(ip 192.168.18.61/24)网关(192.168.18.1)dns(192.168.18.1)
          mail.zbkb.com(ip 172.16.18.61/16) 网关(172.16.18.1) dns(172.16.18.1)
          dns.localdomain(eth0 192.168.18.1/24 eth1 172.16.18.1/16)
1. 在mail.zbka.com安装postfix服务,并配置
vim /etc/postfix/main.cf
myhostname = mail.zbka.com
mydomain = zbka.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, $mydomain
mynetworks = 192.168.18.0/24, 127.0.0.0/8
relay_domains = $mydestination
service postfix restart
chkconfig postfix on
vim /etc/sysconfig/saslauthd
MECH=shadow
service saslauthd restart
chkconfig saslauthd on
2.设置postfix启用smtp认证
vim /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
service postfix restart
3.安装pop服务:dovecot
vim /etc/dovecot.conf
protocols = pop3 pop3s
 protocol pop3 {
     listen = *:10100
}
service dovecot start
chkconfig dovecot on
4.安装IMAP服务:cyrus-imapd
passwd cyrus   //为管理员设置密码
vim /etc/postfix/main.cf
 mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
service postfix restart
cyradm -u cyrus localhost  //为用户创建邮件信箱
cm user.aaa
cm user.aaa.Send
cm user.aaa.Trash
cm user.aaa.Drafts
setquota user.aaa 5210
5.Web方式收发邮件
安装squirrelmail
/usr/share/squirrelmail/config/conf.pl  //打开配置工具
6.同上配置mail.zbkb.com的postfix服务
设置ip为(172.168.18.61/16)
创建用户bbb邮箱
7.配置dns.localdomain服务器
(1)设置(eth0 192.168.18.1/24 eth1 172.16.18.1/16)
(2)echo 1 > /proc/sys/net/ipv4/ip_forward  //开启网卡转发
     vim /etc/sysctl.conf     //永久开启
       net.ipv4.ip_forward = 1
(3)配置dns服务
(1)vim named.conf
options {
        directory         "/var/named";
};
zone    "zbka.com"     {
        type     master;
        file     "zbka.com.zone";
};
zone    "zbkb.com"     {
        type     master;
        file     "zbkb.com.zone";
};

 (2)vim zbka.com.zone
@               IN SOA  dns   root (
                                        20121205        ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
zbka.com.        IN NS           master.zbka.com.
zbka.com.        IN MX 10        mail.zbka.com.
mail             IN A            192.168.18.61
vim zbkb.com.zone
@               IN SOA  dns   root (
                                        20121205        ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
zbkb.com.        IN NS           master.zbkb.com.
zbkb.com.        IN MX 10        mail.zbkb.com.
mail             IN A            172.16.18.61
(4)service named restart  //重启服务
(5)vim /etc/resolv.conf   //清空dns指向
8.客户端互发邮件测试。
http://mail.zbka.com/webmail
http://mail.zbkb.com/webmail