1.Postfix简介

postfix是Wietse Venema在IBMGPL协议之下开发的MTA(邮件传输代理)软件。postfix是Wietse Venema想要为使用最广泛的sendmail提供替代品的一个尝试。在Internet世界中,大部分的电子邮件都是通过sendmail来投递的,大约有100万用户使用sendmail,每天投递上亿封邮件。这真是一个让人吃惊的数字。Postfix试图更快、更容易管理、更安全,同时还与sendmail保持足够的兼容性。

2.postfix的特点

(1) postfix是免费的: postfix想要作用的范围是广大的Internet用户,试图影响大多数的Internet上的电子邮件系统,因此它是免费的。 

(2) 更快: postfix在性能上大约比sendmail×××倍。一部运行postfix的台式PC每天可以收发上百万封邮件。 

(3) 兼容性好:  postfix是sendmail兼容的,从而使sendmail用户可以很方便地迁移到postfix。Postfix支持/var[/spool]/mail、/etc/aliases、 NIS、和 ~/.forward 文件。 

(4) 更健壮: postfix被设计成在重负荷之下仍然可以正常工作。当系统运行超出了可用的内存或磁盘空间时,postfix会自动减少运行进程的数目。当处理的邮件数目增长时,postfix运行的进程不会跟着增加。 

(5) 更灵活: postfix是由超过一打的小程序组成的,每个程序完成特定的功能。你可以通过配置文件设置每个程序的运行参数。 

(6) 安全性:   postfix具有多层防御结构,可以有效地抵御恶意***者。如大多数的postfix程序可以运行在较低的权限之下,不可以通过网络访问安全性相关的本地投递程序等等。

3.SASL简介

SASL全称Simple Authentication and Security Layer,是一种用来扩充C/S模式验证能力的机制。在Postfix可以利用SASL来判断用户是否有权使用转发服务,或是辨认谁在使用你的服务器。 SASL提供了一个通用的方法为基于连接的协议增加验证支持,而XMPP使用了一个普通的XML名字空间来满足SASL的需要。

 

本次试验我们使用postfix在web在进行身份验证的邮件收发的使用。

 

1.由于sendmail是默认开启的,为了便于实验的完成,我们首先要将sendmail卸载掉(也可以将其关闭)

[root@localhost Server]# yum remove sendmail

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Remove Process

*****************************

Is this ok [y/N]: y  (卸载过程中的提示选择“y”)

*****************************

Removed:

  sendmail.i386 0:8.13.8-2.el5                                                                                    

Dependency Removed:

  fetchmail.i386 0:6.3.6-1.1.el5          mdadm.i386 0:2.6.9-2.el5          mutt.i386 5:1.4.2.2-3.0.2.el5        

  redhat-lsb.i386 0:3.1-12.3.EL         

Complete!

[root@localhost Server]#

2.安装实验所需的软件包

[root@localhost Server]# yum install  bind bind-chroot caching-nameserver

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

rhel-server                                                                                 | 1.3 kB     00:00    

rhel-server/primary                                                                         | 732 kB     00:00    

rhel-server                                                                                              2292/2292

Setting up Install Process

*****************************

Total download size: 1.1 M

Is this ok [y/N]: y (在这里一样选择“y”)

*****************************

Downloading Packages:

Is this ok [y/N]: y  (选择“y”)

*****************************

Installed:

  bind.i386 30:9.3.6-4.P1.el5    bind-chroot.i386 30:9.3.6-4.P1.el5    caching-nameserver.i386 30:9.3.6-4.P1.el5  

Complete!

[root@localhost Server]#

3.配置DNS

wps_clip_p_w_picpath-30879

[root@localhost etc]#vim named.conf

wps_clip_p_w_picpath-5565

4.编辑区域声明文件,修改如下

[root@localhost etc]# vim named.rfc1912.zones

wps_clip_p_w_picpath-30814

wps_clip_p_w_picpath-10047

wps_clip_p_w_picpath-18497

设置为开机启动

[root@localhost named]# chkconfig named on

[root@localhost named]# service named start

启动 named:                                               [确定]

[root@localhost named]#

[root@localhost named]# vim /etc/resolv.conf

wps_clip_p_w_picpath-1659

wps_clip_p_w_picpath-10618

修改主机名

[root@localhost named]# vim /etc/sysconfig/network

wps_clip_p_w_picpath-9002

重新启动linux系统,查看服务情况

[root@localhost named]# init 6

wps_clip_p_w_picpath-23295

5.搭建postfixf服务器,这里我们要安装一下postfix(由于系统重新启动,所以要记得重新挂载光盘)

[root@mail ~]# yum install postfix

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

*****************************

Installing:

postfix                 i386                 2:2.3.3-2.1.el5_2                  rhel-server                 3.6 M     

Total download size: 3.6 M

Is this ok [y/N]: y   (选择“y”)

*****************************

Installed:

  postfix.i386 2:2.3.3-2.1.el5_2                                                                                  

Complete!

[root@mail ~]#

[root@mail ~]# vim /etc/postfix/main.cf

wps_clip_p_w_picpath-7683

wps_clip_p_w_picpath-18911

wps_clip_p_w_picpath-2625

将以下内容添加到配置文件中

broken_sasl_auth_clients = yes

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options =noanonymous

smtpd_recipient_restrictions =

permit_mynetworks,   (中继本地网段)

permit_sasl_authenticated,   (中级通过sasl验证的)

reject_unauth_destination   (拒绝未验证的)

wps_clip_p_w_picpath-21803

建立两个用户“user1”“user2”,密码都设为“123”

wps_clip_p_w_picpath-2158

可以查看一下

wps_clip_p_w_picpath-18967

只允许本机进行中继

[root@mail ~]# vim /etc/postfix/main.cf

wps_clip_p_w_picpath-27762

设置postfix服务开机自动启动

[root@mail ~]# chkconfig postfix on

[root@mail ~]# service postfix restart

关闭 postfix:                                             [确定]

启动 postfix:                                             [确定]

6.安装邮件接收服务器dovecot

[root@mail ~]# yum install dovecot

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

rhel-server                                                                                 | 1.3 kB     00:00    

Setting up Install Process

Resolving Dependencies  

*****************************

Total download size: 7.2 M

Is this ok [y/N]: y   (选择“y”)

*****************************

Installed:

  dovecot.i386 0:1.0.7-7.el5                                                                                      

Dependency Installed:

  mysql.i386 0:5.0.77-3.el5        perl-DBI.i386 0:1.52-2.el5        postgresql-libs.i386 0:8.1.11-1.el5_1.1      

Complete!

[root@mail ~]#

启动dovecot服务

[root@mail ~]# service dovecot start

启动 Dovecot Imap:                                        [确定]

[root@mail ~]#

查看端口开启情况

wps_clip_p_w_picpath-8777

7.安装sasl用来实现对用户的身份验证

[root@mail ~]# yum install cyrus*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

*****************************      

Total download size: 15 M

Is this ok [y/N]: y  (选择“y”)

*****************************

Installed:

  cyrus-imapd.i386 0:2.3.7-7.el5       cyrus-imapd-devel.i386 0:2.3.7-7.el5 cyrus-imapd-perl.i386 0:2.3.7-7.el5 

  cyrus-imapd-utils.i386 0:2.3.7-7.el5 cyrus-sasl-devel.i386 0:2.1.22-5.el5 cyrus-sasl-gssapi.i386 0:2.1.22-5.el5

  cyrus-sasl-ldap.i386 0:2.1.22-5.el5  cyrus-sasl-md5.i386 0:2.1.22-5.el5   cyrus-sasl-ntlm.i386 0:2.1.22-5.el5 

  cyrus-sasl-sql.i386 0:2.1.22-5.el5 

Dependency Installed:

  db4-utils.i386

0:4.3.29-10.el5                           lm_sensors.i386 0:2.10.7-4.el5   

Complete!

[root@mail ~]#

修改配置文件

wps_clip_p_w_picpath-28989

设置开机启动并查看端口号

wps_clip_p_w_picpath-7529

8.安装squirrel的包,实现对postfix的web的访问和管理

[root@mail ~]# yum install squirrelmail -y

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process    

*****************************

Total download size: 11 M

*****************************

Installed:

  squirrelmail.noarch 0:1.4.8-5.el5_3.7                                                                           

Dependency Installed:

  apr.i386 0:1.2.7-11.el5_3.1           apr-util.i386 0:1.2.7-7.el5_3.2         gmp.i386 0:4.1.4-10.el5          

  httpd.i386 0:2.2.3-31.el5             php.i386 0:5.1.6-23.2.el5_3             php-cli.i386 0:5.1.6-23.2.el5_3  

  php-common.i386 0:5.1.6-23.2.el5_3    php-mbstring.i386 0:5.1.6-23.2.el5_3  

Complete!

[root@mail ~]#

[root@mail ~]# /usr/share/squirrelmail/config/conf.pl

2  1  bj.com    2  S  R

4  5  y  S  R

1  zh_CN   2  gb2312  S  R

D  dovecot

q

wps_clip_p_w_picpath-20090

wps_clip_p_w_picpath-22644

wps_clip_p_w_picpath-26933

wps_clip_p_w_picpath-22619

wps_clip_p_w_picpath-24152

wps_clip_p_w_picpath-27389

9.设置虚拟目录

[root@mail ~]# vim /etc/httpd/httpd.conf

wps_clip_p_w_picpath-24173

重新启动httpd服务

[root@mail ~]# chkconfig httpd on

[root@mail ~]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using mail.bj.com for ServerName

                                                           [确定]

[root@mail ~]#

10.在IE浏览器上登录http://192.168.2.50/mail,进入以下界面,开始邮件的收发测试

wps_clip_p_w_picpath-6262

wps_clip_p_w_picpath-19458

点击“发送”,然后登陆user2查看是否收到邮件

wps_clip_p_w_picpath-28758

wps_clip_p_w_picpath-23205

 

这样我们就搭建了一个简单的邮件收发服务器,我们将继续学习接下来的内容。