1。安装centos4.4,安装时只选择一个"开发工具"的包,其它都不勾选,安装完毕;
 
2。配置yum更新库:
[root@mail]# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
还有一个导入:(此处暂不导入)
 
3。解决putty连接显示乱码:
vi /etc/sysconfig/i18n将里面内容替换成下面;
LANG="en_US:en"
SUPPORTED="en_US:en:en_US:zh:en_US.en:en_US:en"
SYSFONT="latarcyrheb-sun16"
 
4。关闭cups(打印服务),
[root@mail log]# /etc/rc.d/init.d/cups stop
Stopping cups:                                             [  OK  ]
[root@mail log]# chkconfig cups off
[root@mail log]#
5。解决时间同步问题:
[root@mail ~]# yum install ntp
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 ntp                     i386       4.2.0.a.20040617-6.el4  base              1.2 M
Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 1.2 M
Is this ok [y/N]: y
安装完毕后,就可以有ntpdatae命令了,可以使用ntpdate 命令进行同步了!否则没有ntpdate命令。
[root@mail /]# vi /etc/crontab
将下面:
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
修改为:
#01 * * * * root run-parts /etc/cron.hourly
#02 4 * * * root run-parts /etc/cron.daily
#22 4 * * 0 root run-parts /etc/cron.weekly
#42 4 1 * * root run-parts /etc/cron.monthly
并添加命令行:意思是每隔三分钟与时钟服务器210.72.145.44同步一次时间
*/3 * * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
改完后重启一下服务:
[root@mail /]# service crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]
[root@mail /]#
 
6.安装postfix,dovecot,apache,其中蓝色字体,是相依赖的包,绿色为安装的顺序;
查看域名MX记录
[root@mail postfix]# host -t mx centos.eb.cn
centos.eb.cn mail is handled by 10 mail.centos.eb.cn.
[root@mail etc]yum install postfix
 
[root@mail etc]yum  install dovecot
Dependencies Resolved
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 
dovecot                 i386       0.99.11-8.EL4    base              614 k
Installing for dependencies:
 mysql                   i386       4.1.20-2.RHEL4.1  base              2.9 M
 perl-DBI                i386       1.58-2.el4.rf    dag               819 k
 perl-Net-Daemon         noarch     0.43-1.el4.rf    dag                44 k
 perl-PlRPC              noarch     0.2020-1.el4.rf  dag                33 k
 postgresql-libs         i386       7.4.17-1.RHEL4.1  update            147 k
Transaction Summary
=============================================================================
Install      6 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 4.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): postgresql-libs-7.  16% |====                     |  24 kB    00:39 ETA

Installing: perl-Net-Daemon              ######################### [1/6]
  Installing: perl-PlRPC                   ######################### [2/6]
  Installing: perl-DBI                     ######################### [3/6]
  Installing: mysql                        ######################### [4/6]
  Installing: postgresql-libs              ######################### [5/6]
  Installing: dovecot                      ######################### [6/6]
[root@mail etc]yum  install httpd
=============================================================================
 Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
 
httpd                   i386       2.0.52-32.3.ent.centos4  update            888 k
Installing for dependencies:
 apr                     i386       0.9.4-24.5.c4.2  base               88 k
 apr-util                i386       0.9.4-21         base               51 k
 httpd-suexec            i386       2.0.52-32.3.ent.centos4  update             29 k
Updating for dependencies:
 initscripts             i386       7.93.29.EL-1.centos4  base              1.1 M
Transaction Summary
=============================================================================
Install      4 Package(s)
Update       1 Package(s)
Remove       0 Package(s)
Total download size: 2.2 M
Downloading Packages:
(1/5): initscripts-7.93.2   9% |==                       | 112 kB    03:09 ETA
Running Transaction
  Installing: apr                          ######################### [1/6]
  Installing: apr-util                     ######################### [2/6]
  Updating  : initscripts                  ######################### [3/6]
  Installing: httpd                        ######################### [4/6]
  Installing: httpd-suexec                 ######################### [5/6]
  Cleanup   : initscripts                  ######################### [6/6]


7。POSTFIX的配置方法:
[root@mail /]# cd /etc/postfix
[root@mail postfix]# cp main.cf main.cf.bak
[root@mail postfix]# vi main.cf修改如下面所示:粉色字为待修改,绿色为修改后)
#myhostname = host.domain.tld
myhostname = mail.centos.eb.cn

#mydomain = domain.tld
mydomain = centos.eb.cn
#myorigin = $mydomain
myorigin = $mydomain

inet_interfaces = localhost
#inet_interfaces = localhost
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

#relay_domains = $mydestination
relay_domains = $mydestination
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
mynetworks = 10.0.0.0/8, 127.0.0.0/8
#home_mailbox = Maildir/
home_mailbox = Maildir/
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_banner = $myhostname ESMTP mailserver maintanace by  ---Weihu.Yan---
(此段追加在文件结尾)
#append smtp auth config
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 20971520 
(表附件大小为20M,20*1024*1024)
 
配置SMTP认证:
[root@mail postfix]# vi /usr/lib/sasl2/smtpd.conf修改如下:
pwcheck_method: saslauthd
#pwcheck_method: saslauthd
pwcheck_method: auxprop (表示不使用系统用户认证)

[root@mail postfix]# vi /etc/sysconfig/saslauthd
MECH=shadow  找到这一行,在前面加#
#MECH=shadow 
FLAGS=  找到此行,在等号后面添加“sasldb”
FLAGS=sasldb  定义认证方式为sasldb2

 
建立用户邮箱模板:
[root@mail postfix]# mkdir /etc/skel/Maildir
[root@mail postfix]# chmod 700 /etc/skel/Maildir
若已有用户,刚为已存在用户建立邮箱的方法如下:
[root@mail ~]# mkdir /home/leeki.yan/Maildir  为用户(这里以leeki.yan用户为例)建立邮箱目录
[root@mail ~]# chmod 700 /home/leeki.yan/Maildir  设置该用户邮箱目录属性为700
[root@mail ~]# chown leeki.yan. /home/leeki.yan/Maildir  设置该用户邮箱目录为该用户所有
 
为用户设置SMTP密码:(以root账户为例)
[root@mail postfix]# saslpasswd2 -u mail.centos.eb.cn -c root
Password:
Again (for verification):
[root@mail postfix]#
 
改变SASL的归属
[root@mail postfix]# chgrp postfix /etc/sasldb2
[root@mail postfix]# chmod 640 /etc/sasldb2
关闭sendmail,及设置不自动启动,并修改默认的MTA
[root@mail postfix]# /etc/rc.d/init.d/sendmail stop
Shutting down sendmail:                                    [  OK  ]
Shutting down sm-client:                                   [  OK  ]
[root@mail postfix]# chkconfig sendmail off
[root@mail postfix]# chkconfig --list sendmail
sendmail        0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@mail postfix]# alternatives --config mta
There are 2 programs which provide 'mta'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
   2           /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
[root@mail postfix]#
启动SMTP认证及Postfix服务,并设置相应服务为自启动
[root@mail postfix]# chkconfig saslauthd on
[root@mail postfix]# chkconfig --list saslauthd
saslauthd       0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@mail postfix]# chkconfig postfix on
[root@mail postfix]# chkconfig --list postfix
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@mail postfix]# /etc/rc.d/init.d/saslauthd start
Starting saslauthd:                                        [  OK  ]
[root@mail postfix]# /etc/rc.d/init.d/postfix start
Starting postfix:                                          [  OK  ]
[root@mail postfix]#
查看smtp端口是否为打开
[root@mail postfix]# netstat -tl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:809                       *:*                         LISTEN
tcp        0      0 *:sunrpc                    *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 *:smtp                      *:*                         LISTEN
[root@mail postfix]#
 
8。配置dovecot
[root@mail etc]# vi /etc/dovecot.conf(修改如下面所示:粉色字为待修改,绿色为修改后)
#protocols = imap imaps
protocols = imap imaps pop3 pop3s
#default_mail_env =
default_mail_env = maildir:~/Maildir   (定义邮箱的目录)
[root@mail etc]# vi /etc/sysconfig/iptables
添加以下部分:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT 为pop3
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT 为imap
[root@mail etc]# /etc/rc.d/init.d/iptables restart
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
[root@mail etc]#
[root@mail etc]# chkconfig dovecot on
[root@mail etc]# chkconfig --list dovecot
dovecot         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@mail etc]# /etc/rc.d/init.d/dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[root@mail etc]#
至此可以测试收发,邮箱服务器的基本功能已实现!
[root@mail etc]# useradd leeki.yan -s /sbin/nologin
[root@mail etc]# passwd leeki.yan
Changing password for user leeki.yan.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
添加用户测试看看吧!