测试环境:RHEL5.3 Sendmail、Dovecot为安装光盘自带版本。
  (所有软件包都通过本地YUM源安装,如有疑问请参照: http://iminmin.blog.51cto.com/689308/162666中搭建光盘YUM源)
一、    Sendmail服务概况:
    1、需要的软件包:sendmail(默认已安装) sendmail-cf sednmail-doc
    2、端口: 25(SMTP)
    3、相关配置文件:/etc/mail/*
    4、系统收到邮件保存在/var/spool/mail/[linux用户名]。
二、Dovecot概况:
    1、功能:主要提供imap imaps pop3 pop3s服务。其中imaps pop3s是使用SSL来加密验证和数据安全的服务器。
    2、端口: 110(pop)  995(pop3s)  143(imap)  993(imaps)
    3、相关配置文件:/etc/dovecot.conf
三、Sendmail服务架设:
    1、配置DNS服务器:
    DNS服务器按照Blog中以前的文章来配置。
反向DNS配置: http://iminmin.blog.51cto.com/689308/193710;(由于其他原因,本文章中和以上两篇文章中只有IP地址改成了192.168.10.1其他保持不变)。
    2、安装Sendmail软件包:
-----------------------------------------------------
[root@rhel53 mail]# yum install senmail* -y
-----------------------------------------------------
3、修改Sendmail相关配置文件:
    1)/etc/mail/sendmail.mc:主要两个部分,红色为修改后的内容。
    DAEMON_OPTIONS(`Port=smtp,Addr= 0.0.0.0, Name=MTA')dnl  //扩大监听范围为所有IP。
    LOCAL_DOMAIN(` mail.rhce.cn')dnl   //修改成自己的邮件服务域名。
    4、用m4命令将sendmail.mc的内容导入到sendmail.cf文件中:
----------------------------------------------------
[root@rhel53 mail]# pwd
/etc/mail
[root@rhel53 mail]# m4 sendmail.mc  >sendmail.cf
----------------------------------------------------
5、修改:修改/etc/mail/local-host-names  Sendmail设置要收取那些域名的信,如果没有就不会收取。
----------------------------------------------------
[root@rhel53 mail]# vim local-host-names
# local-host-names - include all aliases for your machine here.
mail.rhce.cn
rhce.cn
----------------------------------------------------
6、重新启动相关服务进行测试:
    1)服务的重新启动:
---------------------------------------------------
[root@rhel53 mail]# chkconfig sendmail on
[root@rhel53 mail]# service sendmail restart
Shutting down sm-client:         [ OK ]
Shutting down sendmail:         [ OK ]
Starting sendmail:                    [ OK ]
Starting sm-client:                   [ OK ]
--------------------------------------------------
2)本地发送收取邮件测试:
--------------------------------------------------
[root@station1 mail]# mail redhat@mail.rhce.cn    //写邮件。
Subject: test  this is a test
please let go!
this is a test !
the mail is ben a test!
.                                           //写邮件结束标志。
Cc:
--------------------------------------------------
邮件发送以后可能要经过一段时间(2-5分钟)才能看到邮件。
--------------------------------------------------
[root@station1 mail]# mail -u redhat     //阅读redhat的邮件。
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/redhat": 1 message 1 new
>N  1 root@station1.cn      Fri Aug 21 07:51  18/635   "test  this is a test"
&                                       
//提示有一份邮件记录。标题和我们发送的时候写的标题相同。
-------------------------------------------------
经过上面的测试我们的Sendmail邮局就好了,当然我们可能要考虑的问题是一个工作的方便性,不可能让大家都在Linux的终端界面这么发邮件,下面我们就看一下通过Dovecot来实现通过邮件客户端软件(outlook)来发送接收邮件。
四、Dovecot下pop3 imap的及邮件客户端软件的使用:
1、Dovecot软件包的安装
-----------------------------------------------------
[root@rhel53 mail]# yum install dovecot* -y
-----------------------------------------------------
2、修改/etc/dovevcot.conf配置文件:
    protocols =pop3 imap imaps pop3s  //这句,去掉前面的#,修改成前面的样
3、重启动相关服务:
-----------------------------------------------------
[root@rhel53 mail]# chkconfig dovecot on
[root@rhel53 mail]# service dobecot restart
[root@rhel53 mail]# service sendmail restart
----------------------------------------------------
4、Outlook的配置:(pop3为例,imap大家实现pop3后自己配置一下)
**
**
**
**
**
配置好以后会出现登陆账号提示,输入密码就可以看见邮件,并做发送邮件测试了。
通过上面的努力,我们就实现了Sendmail+dovecot组合的邮局服务+邮件客户端的使用。
备注:
该次实验的iptables服务是关闭的,如果开启该服务,请将文中介绍的端口都打开,再测试。