Postfix + web + 身份驗證

 

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

 

這樣我們就搭建了一個簡單的郵件收發服務器,我們將繼續學習接下來的內容。

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章