(一)postfix的安装 1.停用sendmail服务,并设置默认启动状态为关闭
[iyunv@svr1 ~]# service sendmail stop
2.编译安装 源码编译及安装postfix
a. 创建postfix程序用户及程序组
[iyunv@svr1 ~]# groupadd -g 1200 postdrop
[iyunv@svr1 ~]# groupadd -g 1000 postfix
[iyunv@svr1 ~]# useradd -M -g postfix -G postdrop -s /sbin/nologin postfix
b.解包、预配置、编译、安装
[iyunv@svr1 postfix-2.8.2]# make makefiles 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl' 'AUXLIBS=-L/usr/libsasl2 -lsasl2' ;make ; make install
c.Postfix服务控制
[iyunv@svr1 postfix-2.8.2]# postfix start
postfix/postfix-script: starting the Postfix mail system
d.简化postfix邮件服务器主配置文件main.cf
[iyunv@svr1 ~]# cd /etc/postfix/
[iyunv@svr1 postfix]# ls
access bounce.cf.default generic LICENSE main.cf.default master.cf TLS_LICENSE virtual
aliases canonical header_checks main.cf makedefs.out relocated transport
[iyunv@svr1 postfix]# postconf -n > tem.file
[iyunv@svr1 postfix]# mv main.cf main.cf.bak
[iyunv@svr1 postfix]# mv tem.file main.cf
5.编辑主配置文件,添加以下几行
inet_interfaces = 169.254.87.2, 127.0.0.1
myhostname = mail.benet.com
mydomain = benet.com
myorigin = $mydomain
mydestination = $mydomain, $myhostname
home_mailbox = Maildir/
6.添加邮箱账号并测试
[iyunv@svr1 postfix]# groupadd mailusers
[iyunv@svr1 postfix]# useradd -g mailusers -s /sbin/nologin xinlei
[iyunv@svr1 postfix]# useradd -g mailusers -s /sbin/nologin zhigang
[iyunv@svr1 postfix]# passwd xinlei / zhigang 密码都是123
[iyunv@svr1 postfix]# telnet mail.benet.com 25
helo mail.benet.com
mail from:xinlei@benet.com
rcpt to:zhigang@benet.com
data
subject:A test mail
aa
gg
h
.
quit (编译安装Dovecot 邮件接收服务器)
a.创建程序用户
[iyunv@svr1 ~]# useradd -M -s /sbin/nologin dovecot
[iyunv@svr1 ~]# useradd -M -s /sbin/nologin dovenull
b.编译安装
[iyunv@svr1 ~]# cd /soft/LNS/chapter10
[iyunv@svr1 chapter10]# tar zxf dovecot-2.0.12.tar.gz -C /usr/src/
[iyunv@svr1 chapter10]# cd /usr/src/dovecot-2.0.12/
[iyunv@svr1 dovecot-2.0.12]# ./configure --sysconfdir=/etc ; make ; make install
c.添加系统服务dovecot
[iyunv@svr1 dovecot-2.0.12]# cp doc/dovecot-initd.sh /etc/init.d/dovecot
[iyunv@svr1 dovecot-2.0.12]# chmod +x /etc/init.d/dovecot
[iyunv@svr1 dovecot-2.0.12]# chkconfig --add dovecot
d.建立配置文件,并启动服务
a. 建立配置文档
[iyunv@svr1 dovecot-2.0.12]# cp -r /usr/local/share/doc/dovecot/example-config/* /etc/dovecot/
auth required pam_nologin.so
auth include system-auth
account include system-auth
session include system-auth
b. 调整主配置文件
83 !include conf.d/10-auth.conf
84 ssl = no
85 disable_plaintext_auth = no
86 mail_location = maildir:~/Maildir
e. 启动dovecot
[iyunv@svr1 dovecot-2.0.12]# /etc/init.d/dovecot start
Starting Dovecot.
[iyunv@svr1 dovecot-2.0.12]# netstat -antpl | grep dovecot
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 16028/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 16028/dovecot
tcp 0 0 :::110 :::* LISTEN 16028/dovecot
tcp 0 0 :::143 :::* LISTEN 16028/dovecot
f. POP3接收邮件测试
[iyunv@svr1 dovecot-2.0.12]# telnet mail.benet.com 110
user zhigang
pass 123
list
retr 1
quit
|