Sendmail——Linux/UNIX的邮件服务器开朝元老。 作为一种免费的邮件服务器软件,已被广泛的应用于各种服务器中,它在稳定性、可移植性、及确保没有bug等方面具有一定的特色,且可以在网络中搜索到大量的使用资料。
虽然Sendmail存在着种种的问题,但是,笔者认为Sendmail仍是搭建服务器的一个好的选择,本篇,笔者将和您共同探讨Sendmail在企业环境中的应用。
实验要求:某企业有两家子公司,分别位于上海和北京。现企业拟计划建立邮件服务器,方便该公司用户进行交流。
实验拓扑:
实验设备:DNS_Server && Mail Server (Linux 5.4 (2.6.18-164.el5)
) 两台
Client (windows xp)两台
实验步骤:
一、bj.com配置
1.安装sendmail
[root@ns ~]# yum list |grep -E "sendmail"
This system is not registered with RHN.
RHN support will be disabled.
sendmail.i386 8.13.8-2.el5 installed
sendmail-cf.i386 8.13.8-2.el5 rhel-Server
sendmail-devel.i386 8.13.8-2.el5 rhel-Server
sendmail-doc.i386 8.13.8-2.el5 rhel-Server
[root@ns ~]# yum install -y sendmail-cf.i386
[root@ns ~]# rpm -qa |grep -E "sendmail|m4"
m4-1.4.5-3.el5.1
sendmail-cf-8.13.8-2.el5
sendmail-8.13.8-2.el5
2.修改sendmail有关文件
[root@ns ~]#
[root@ns mail]# pwd
/etc/mail
[root@ns mail]# vim sendmail.mc
[root@ns mail]# vim access
[root@ns mail]# vim local-host-names
[root@ns mail]# service sendmail start
Starting sendmail:
[root@ns mail]# service sendmail restart
Shutting down sm-client: [ OK ]
Shutting down sendmail: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
[root@ns mail]#
3.Sendmail测试
添加用户
[root@ns ~]# useradd user1
[root@ns ~]# echo "123"|passwd --stdin user1
Changing password for user user1.
passwd: all authentication tokens updated successfully.
[root@ns mail]# telnet 127.0.0.1 25
4.安装dns
[root@ns Server]# pwd
/mnt/cdrom/Server
[root@ns Server]# rpm -ivh bind-9.3.6-4.P1.el5.i386.rpm
[root@ns Server]# rpm -ivh bind-chroot-9.3.6-4.P1.el5.i386.rpm
[root@ns Server]# rpm -ivh caching-nameserver-9.3.6-4.P1.el5.i386.rpm
5.修改dns有关配置
[root@ns etc]# pwd
/var/named/chroot/etc
[root@ns etc]# cp -p named.caching-nameserver.conf named.conf
[root@ns etc]# vim named.conf
[root@ns etc]# pwd
/var/named/chroot/etc
[root@ns etc]# vim named.rfc1912.zones
[root@ns etc]# cd /var/named/chroot/var/named/
[root@ns named]# cp localhost.zone bj.com.db
[root@ns named]# vim bj.com.db
[root@ns named]# pwd
/var/named/chroot/var/named
[root@ns named]# cp -p named.local 192.168.10.db
[root@ns named]# vim 192.168.10.db
[root@ns named]# rndc reload
server reload successful
[root@ns named]# service named start
Starting named: [ OK ]
[root@ns named]#
[root@ns named]# chkconfig named on
[root@ns named]# chkconfig --list |grep named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6.修改有关主机信息
[root@ns named]# vim /etc/resolv.conf
[root@ns named]# hostname
ns.bj.com
[root@ns named]# vim /etc/sysconfig/network
[root@ns named]# vim /etc/hosts
[root@ns named]# init 6
7.安装dovecot
[root@mail ~]# yum list all |grep dov
This system is not registered with RHN.
RHN support will be disabled.
dovecot.i386 1.0.7-7.el5 rhel-Server
[root@mail ~]# yum install dovecot.i386 -y
8.修改dovecot有关配置
[root@mail ~]# service dovecot start
Starting Dovecot Imap: [ OK ]
[root@mail ~]# chkconfig dovecot on
[root@mail ~]# chkconfig --list |grep dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail ~]# netstat -tupln |grep dovecot
tcp 0 0 :::993 :::* LISTEN 3179/dovecot
tcp 0 0 :::995 :::* LISTEN 3179/dovecot
tcp 0 0 :::110 :::* LISTEN 3179/dovecot
tcp 0 0 :::143 :::* LISTEN 3179/dovecot
[root@mail ~]#
[root@mail ~]# grep 993 /etc/services
imaps 993/tcp # IMAP over SSL
imaps 993/udp # IMAP over SSL
[root@mail ~]# grep 995 /etc/services
pop3s 995/tcp # POP-3 over SSL
pop3s 995/udp # POP-3 over SSL
[root@mail ~]# service dovecot restart
Stopping Dovecot Imap: [ OK ]
Starting Dovecot Imap: [ OK ]
[root@mail ~]# netstat -tupln |grep dovecot
tcp 0 0 :::110 :::* LISTEN 3294/dovecot
tcp 0 0 :::143 :::* LISTEN 3294/dovecot
[root@mail ~]# vim /etc/dovecot.conf
9.使用本域内主机测试
创建用户
给自己发送邮件
查看自己所发送的邮件
二、Sh.com配置
1.为了加快部署服务器,可以采用克隆。在启动时,最后进入单用户模式修改,更方便
2.修改sendmail有关文件
sh-3.2#cd /etc/mail
sh-3.2#vim access
[root@ns mail]# vim local-host-names
2.修改dns有关配置
sh-3.2#vim /var/named/chroot/etc/name.conf
sh-3.2#vim /var/named/chroot/etc/name.rfc.zones
sh-3.2#cd /var/named/chroot/var/named
sh-3.2#mv bj.com.db sh.com.db
sh-3.2# vim sh.com.db
3.修改有关主机信息
sh-3.2#vim /etc/resolv.conf
sh-3.2#vim /etc/sysconfig/network
sh-3.2# vim /etc/hosts
sh-3.2#init 6
三、测试
1.查看dns解析
2.使用[email protected]发送邮件
3.使用[email protected]接收邮件