歡迎您光臨本站 註冊首頁

新手的Centos5.2+postfix安裝配置,請大家校驗.

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

新手的Centos5.2+postfix安裝配置,請大家校驗.

Centos5.2搭建Postfix郵件系統
                                                
序言:
    用了5天的時間,終於現實了我要達到目標.最開始的2天其實已經按著網上的教程現實了本次試驗的目標.但是其中很多錯誤的排查,並沒有及時的紀錄和思考.以及對整個系統所需要的軟體包功能,也沒有多少理解.總覺得第一次的試驗多少是僥倖成功.糊裡糊塗的一次試驗.因此,為了在驗證一次,加深理解.我又從新建了虛擬機,從新安裝操作系統,從新搭建postfix郵件系統.
    多哩羅嗦寫下這長一個文檔,儘可能的紀錄下了每一步操作,及產生錯誤時解決的方法.
    從開始對linux的一無所知到搭建起這個系統,算來已經有3,4個月了.當我看到postfix時,這個系統好大,用了如此多的軟體包.我想我要把它搭起來,會是一件偉大的事,在本論壇的mail伺服器版看了很多很多安裝教程,把<POSTFIX權威指南>粗粗的看了一次.看postfix的安裝教程似乎不是很困難,可是當我一步一步做下來的時候,幾乎每一步都會出錯,有的錯誤一個小時兩個小時都解決不了,我想過放棄,太難了.我還對linux還不了解,等以後我了解多了,在搞它.可我又想,這麼複雜的一個系統,我要把它拿下,多有成就感.好吧,有錯不怕,見一個解決一個,能解決一個是一個,大不了最後失敗.
     兩天的時間,解決著每個出現的錯誤,解決一個,我就似乎看到成功不遠了.最後當我現實了我想要到達的目標時,感覺迷迷糊糊的,什麼都沒明白,就是解決錯誤了.於是我想在從來一次吧.做一件事,總的讓自己清楚是做了些什麼.當然最重要的是把過程記錄下來,以後多練習,多總結.總有一天我不會再用一周的時間才能把它搞定.第二次依舊有很多出現了大量錯誤,加上我邊做別記錄操作,花了3天時間.
    在此次試驗過程中,很多的錯誤都是由於輸入的參數和配置錯誤引起的,仔細要仔細.試驗不是為了一點錯都不出錯就成功的,那樣似乎沒有任何成就感,而且網上到處都是基本的安裝配置教程,學習不是為了按著教程一步不犯錯的完成,這樣似乎失去了意義,就是要出錯,學的就是一種排查和解決錯誤的能力.
    到現在越學,越覺得linux太複雜了,太難了.似乎依舊不得要領,無法入門,寫這麼多廢話,希望能和大家分享和探討下學習linux方法和經驗.歡迎大家批評指正.
    在此,感謝網上那些分享教程的朋友,感謝本論壇的熱心朋友,雖然我很少提問題,但問的問題,總會獲得論壇里熱心的朋友回答.
    From the Internet,For the Internet.
                                                                                   
   

                                                                                         By Drvial
PDF文檔
一 系統運行環境
1.1硬體要求
      基本上,能夠安裝linux系統就能夠滿足硬體的要求…….
1.2運行環境
      操作系統為centos 5.2+VMware-workstation6.0.
      我使用的VM6虛擬機和Centos5.2做的本次試驗.
1.3所需軟體
      1, Centos 伺服器操作系統
      2, Postfix 郵件伺服器系統的smtp伺服器,在郵件伺服器系統中充當MTA角色.
      3, Mysql 開源資料庫,用於存儲郵件系統虛擬域,虛擬帳戶信息.
      4, apache web伺服器軟體,用於extman對郵件系統的後台管理,extmail的web郵件收發.
      5, php   extman和extmail需要使用php解析
      6, cyrus-sasl 用於實現身份驗證的smtp伺服器
      7, courier-authlib 現實帶驗證的pop3伺服器
      8, courier-imap 用於實現pop3,imap收郵件功能
      9,extman 用於郵件伺服器的後台管理
      10,extmail 用於實現webmail
      11,DBD-mysql 用於解決依賴關係,extmail將會用到
      12,unix-syslog 用於解決依賴關係,extmail將會用到
      13,BerkeleyDB 用於提供資料庫效率
      14, openssl 提供安全的郵件伺服器連接 (本次試驗未配置此功能)
      15, maildrop 用於替代postfix的mta功能,郵件投遞代理,將收到的郵件轉發到用戶的郵箱目錄(本次試驗未配置此功能)
      16,clamav   反病毒工具              (本次試驗未配置此功能)
      17,SpamAssassin  反垃圾郵件過濾器  (本次試驗未配置此功能)
      18,amavisd-new  是一個連接MTA和內容檢測工具  (本次試驗未配置此功能)
二 準備工作
2.1 下載所需要的軟體
     按照上面給出的地址下載,默認情況,本文所有軟體包都放置在/usr/local/src下.所使用的安裝包都為源碼包.
2.2 禁用服務和軟體
     默認環境下,有部分服務和軟體已被起用及安裝到系統里,這些都影響到本系統的安裝.所以需要禁止和卸載.
  2.2.1禁用selinux
     Selinux 是 linux 系統中一個強制性的安全機制,但也帶來了不少麻煩,為了避免不必要的麻煩,還是先關了吧。我之前在 Fedora cora 5 上安裝郵件伺服器時就因為沒有關掉 selinux ,而苦惱了一段時間。
      [root @test root]# vi /etc/selinux/conifg
       # This file controls the state of SELinux on the system.
       # SELINUX= can take one of these three values:
       #       enforcing - SELinux security policy is enforced.
       #       permissive - SELinux prints warnings instead of enforcing.
       #       disabled - SELinux is fully disabled.
              將 SELINUX=enforcing
              改成
              SELINUX=disabled
       # SELINUXTYPE= type of policy in use. Possible values are:
       #       targeted - Only targeted network daemons are protected.
       #       strict - Full SELinux protection.
               SELINUXTYPE=targeted
  2.2.2 卸載sendmail
       默認安裝系統時,sendmail
       查看系統是否安裝sendmail
       # rpm -qa | grep sendmail
       sendmail-8.13.8-2.el5
       卸載
       # rpm -e sendmail
        error: Failed dependencies:
        /usr/sbin/sendmail is needed by (installed) redhat-lsb-3.1-12.3.EL.el5.centos.i386
        smtpdaemon is needed by (installed) mdadm-2.6.4-1.el5.i386
        smtpdaemon is needed by (installed) fetchmail-6.3.6-1.1.el5.i386
        smtpdaemon is needed by (installed) mutt-1.4.2.2-3.0.2.el5.i386
        提示出錯,有相關依賴關係,使用--nodeps強制卸載
        # rpm -e  --nodeps sendmail
        warning: /var/log/mail/statistics saved as /var/log/mail/statistics.rpmsave
        會提示警告不要管,繼續.
  2.2.3 卸載httpd
        # rpm -qa |grep httpd
        httpd-2.2.3-11.el5_1.centos.3
        # rpm -e --nodeps  httpd
        卸載sasl
        # rpm -qa | grep sasl
        cyrus-sasl-plain-2.1.22-4
        cyrus-sasl-lib-2.1.22-4
        cyrus-sasl-2.1.22-4
        # rpm -e --nodeps cyrus-sasl-plain cyrus-sasl-lib cyrus-sasl
2.3 創建郵件系統運行時所需要的用戶和組
       因為安全和管理方面的考慮,一些軟體我們不希望其以root用戶為屬主而運行,甚至有些軟體沒有為其創建專用用戶,安裝不能進行.因此,我們要預先創建postfix系統所用到的用戶和組.對於centos或redhat等發行版,用命令useradd創建用戶時,也就同時創建了一個同名的組.而另外一些linux發行版創建用戶時不會創建同名組,這需要單獨執行groupadd來創建所需組.
       下面是我們需要創建的用戶和組,及其說明.
       用戶名          組名                 作用                                    備註
       mysql           mysql         資料庫mysql運行用戶
       extmail         extmail        虛擬郵件帳號所使用用戶及組            uid:501,gid:501
       postfix          postfix         postfix主程序使用帳號和組
                       postdrop       postfix setid_group                   setgid_group=postdrop
      #這裡有2個值得注意的地方,他們是extmail用戶,組及postdrop.在postfix郵件系統中,有好幾個程序是以extmail來運行,postdrop是postfix主配置文件main.cf里標明的, setgid_group=postdrop.
三 安裝軟體包
3.1 Mysql安裝和配置
  3.1.1 編譯安裝mysql
     # cd /usr/local/src
     # ls
     apache  mysql  php  postfix
     # cd mysql/
     # ls
     mysql-5.1.36.tar.gz
     # tar –zxvf  mysql-5.1.36.tar.gz
     # cd mysql-5.1.36
     [root@mailmysql-5.1.36]#./configure  --prefix=/usr/local/mysql
     --enable-thread-safe-client  --enable-local-infile --with-charset=gbk  --with-low-memory
     #我在這裡出錯了,提示: configure: error: No curses/termcap library found
     #google說是缺少ncurses包,掛載安裝盤,找到ncurses-devel-5.5-24.20060715.i386.rpm安裝
     [root@mailmysql-5.1.36]#make
     [root@mailmysql-5.1.36]#make  install
     make: Entering directory `/data0/software/mysql-5.1.34/mysql-test'
     #到這裡時候會等待很久,我開始以為出錯了,強行終止了,google發行已經有前人沒耐心犯過錯了~
  3.1.2 MySQL配置文件
      如果你想要設置一個選項文件,使用support-files目錄中的一個作為模板。在這個目錄中有4個模板文件,是根據
不同機器的內存定製的。
     # cp support-files/my-medium.cnf /etc/my.cnf
     # cp support-files/mysql.server /etc/rc.d/init.d/mysqld   
  3.1.3設置開機自動啟動
     # chmod 700 /etc/rc.d/init.d/mysqld
     # chkconfig --add mysqld
     # chkconfig --level 345 mysqld on
     # cd /usr/local/mysql/
  3.1.4初始化授權表  
     用mysql_install_db創建MySQL
     # ./bin/mysql_install_db  --user=mysql
     設定目錄訪問許可權,並設置mysql,root帳號訪問許可權。
     # chown -R root .
     # chgrp  -R mysql .
     # chown -R mysql var
  3.1.5 運行mysql
     # bin/mysqld_safe  --user=mysql &
     (如果沒有問題的話,應該會出現類似這樣的提示:
       42264
      #Starting mysqld daemon with databases from /usr/local/mysql/var
      如果出現 mysql ended這樣的語句,表示Mysql沒有正常啟動,你可以到log中查找問題,Log文件的通常在 /etc/my.cnf中配置,大多數問題是許可權設置不正確引起的.
     日誌文件路徑
       mysql安裝路徑(/usr/local/mysql)./var/主機名.err
     我的錯誤日誌路徑 /usr/local/mysql/var/mail.drvial.com.err
  3.1.6 測試mysql
     # bin/mysqladmin  ping
     mysqld is alive
     # bin/mysqladmin  version
     bin/mysqladmin  Ver 8.42 Distrib 5.1.36, for pc-linux-gnu on i686
     Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
     This software comes with ABSOLUTELY NO WARRANTY. This is free software,
     and you are welcome to modify and redistribute it under the GPL license
     Server version          5.1.36-log
     Protocol version        10
     Connection              Localhost via UNIX socket
     UNIX socket             /tmp/mysql.sock
     Uptime:                 5 min 56 sec
     Threads: 1  Questions: 2  Slow queries: 0  Opens: 15  Flush tables: 1  Open tables: 8  Queries per second
     avg: 0.5
     查看3306埠是否打開。要注意在防火牆中開放該埠
     # netstat -atln
     Active Internet connections (servers and established)
     Proto Recv-Q Send-Q Local Address               Foreign Address             State
     tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
  3.1.7設置root密碼
     默認安裝密碼為空,為了安全你需要修改密碼。
       #/usr/local/mysql/bin/mysqladmin –u  root  password 密碼
     修改環境變數文件/etc/profile,添加mysql的PATH變數.
      #vi /etc/profile
      在以下欄位添加添加pathmunge /usr/local/mysql/bin
      # Path manipulation
      if [ "$EUID" = "0" ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
        pathmunge /usr/local/mysql/bin
      也可以做符號連接如下:
      #cd bin
      #for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done
      這樣既可以在任何目錄路徑下,都可以在shell提示符下直接執行/usr/local/mysql/bin下的管理程序.
  3.1.8添加連接庫
    postfix安裝時候會用到,否則報錯.
    #echo 「/usr/local/mysql/lib/mysql」 >> /etc/ls.so.conf
    # ldconfig
     Ok!Mysql安裝完畢.
3.2 安裝apache
  3.2.1 編譯安裝apache
     # cd apache
     # ls
     httpd-2.2.11.tar.gz
     # tar -zxvf httpd-2.2.11.tar.gz
     # ./configure --prefix=/usr/local/apache
     --enable-so  --enable-rewrite --with-zlib  --enable-mods-shared=most
     #make
     #make install
  3.2.2 設置開機自啟動
     # cd /usr/local/apache/bin/
     # cp apachectl  /etc/rc.d/init.d/httpd
     # chmod 700 /etc/rc.d/init.d/httpd
     # vi /etc/rc.d/init.d/httpd
     在# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||下添加下面三行:
     #Comments to support chkconfig on RedHat Linux
      #chkconfig: 2345 90 90
      #description:http server
     注意:前面的#不能少,沒有這三行,在使用chkconfig時會提示你:service httpd does not support chkconfig
     # chkconfig --add httpd
     # chkconfig --level 345 httpd on
     這樣,在運行級別345上httpd就可以自動啟動了。
     對於這個提示:
     httpd: Could not determine the server』s fully qualified domain name, using 127.0.0.1 for ServerName
     只需要編輯httpd.conf,找到ServerName xxxx這一行,去掉前面的註釋即可。
  3.2.3 配置apache
    # cd /usr/local/apache/conf
    # vi httpd.conf
    更改user,group為postfix
    啟動apache
    #service httpd start
    # netstat -atln
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address            Foreign Address           State
    tcp        0      0 :::80                       :::*                        LIST
    ok!apache安裝完畢
3.3 安裝php
  3.3.1 編譯安裝php
     # cd /usr/local/src/php
     # tar -zxvf php-5.2.10.tar.gz
     # cd php-5.2.10
     #./configure  --prefix=/usr/local/php
     --with-apxs2=/usr/local/apache/bin/apxs
     --with-mysql=/usr/local/mysql/
     --with-mysqli=/usr/local/mysql/bin/mysql_config
     --with-zlib --with-gd --enable-mbstring=all
     #我這裡報錯
     checking for xml2-config path…
     configure: error: xml2-config not found. Please check your libxml2 installation.
     #google是缺少libxml2-dev包, 掛載安裝盤找到libxml2-dev包,並安裝.
     #make
     #make install
     # cp php.ini-dist  /usr/local/php/lib/php.ini
  3.3.2編輯apache使支持php
     #vi /usr/local/apache/conf/httpd.conf
     在DirectoryIndex處添加 index.php
     DirectoryIndex   index.html  index.php
     在AddType添加
     AddType application/x-httpd-php  .php
  3.3.3 測試apache是否支持pap
     #vi /usr/local/apache/htdocs/index.html
     編輯apache/htdocs目錄下的index.html
     添加如下代碼
     <?php
     Phpinfo();
     ?>
    保存,重命名為index.php
    #mv  /usr/local/apache/htdocs/index.html  /usr/local/apache/htdocs/index.php
    在瀏覽器輸入http://localhost 或者http://ip,確定apache是否以支持php.
    Ok,php安裝完畢!
3.4 安裝phpmyadmin
    (這個不是必須,用於管理Mysql資料庫)
  3.4.1解壓拷貝到apache目錄下
    將所文件解壓后拷貝到apache的htdocs目錄的某個目錄下.
    # tar -zxvf phpMyAdmin-3.2.0.1-all-languages.tar.gz
    # cp -r phpMyAdmin-3.2.0.1-all-languages  /usr/local/apache/htdocs/phpMyadmin
    # cd /usr/local/apache/htdocs/phpMyadmin/libraries
    phpmyadmin的配置文件是libraries/config.default.php.
    # vi config.default.php
  3.4.2解決需要一個密語驗證的問題
    phpmyadmin登錄MySQL的方式:
    config -- 直接在配置文件中寫入一個能登錄mysql的帳號和密碼,只要瀏覽這個datamgr目錄就可以直接以這個寫入配置文件的mysql帳號進行管理mysql的操作。特點是方便,缺點是沒有安全性。
    http -- 利用web伺服器的驗證功能,瀏覽datamgr這個目錄前會跳出一個身份驗證窗口,只要mysql帳號對得上就可以有datamgr目錄的訪問權。這樣比較安全,不過用cgi或fastcgi的方式配置php將無法使用該功能,因為cgi不會想伺服器發送一些驗證信息變數。
   cookie -- 和http一樣也會跳出一個驗證窗口,不過這個不是用web伺服器的驗證功能,直接是php寫的一個普通登錄窗口,只要瀏覽器支持cookie就行,21世界的瀏覽器都應該支持cookie這個基本功能,所以我們一般選擇cookie驗證方式。
    這些欄位和config.default.php對應的是
    $cfg['Servers'][$i]['auth_type'] = 'cookie';  (valid choices: config, http, HTTP, signon or cookie)
    $cfg['Servers'][$i]['user'] = 'root'; // MySQL user
    $cfg['Servers'][$i]['password'] = ''; // MySQL password (only needed
    config要三處都要填完,http填auth_type為http就行了,cookie的話除了填這裡,還要填寫一個加密用的私鑰,往配置文件的上面找.
    $cfg['blowfish_secret'] = '111';
    blowfish_secret隨便填寫一些字元就行了,如111.
  3.4.3為phpMyadmin安裝mcrypt
    否則會提示以下警告:無法載入 mcrypt 擴展,請檢查您的 PHP 配置
    安裝步驟詳見:
     http://hi.baidu.com/drvial/blog/item/b6b750015f8ac3df277fb5d3.html

[ 本帖最後由 drvial 於 2009-7-20 18:41 編輯 ]
《解決方案》

3.5 安裝courier-authlib
  3.5.1 編譯安裝
   # tar -jxvf courier-authlib-0.62.4.tar.bz2
   # cd courier-authlib-0.62.4
   # ./configure  --prefix=/usr/local/courier-authlib
   --without-authpam  - -without-authdap  --without-authshadow  --without-vchkpw  --with-authmysql
   --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql
   #make
   #make install
  3.5.2 配置authlib
   # cd /usr/local/courier-authlib/
   # chmod 755 var/spool/authdaemon/
   # cd etc/authlib/
   # cp authdaemonrc.dist  authdaemonrc
   # cp authmysqlrc.dist  authmysqlrc
   # vi authdaemonrc
   修改/etc/authdaemonrc 文件為:
   authmodulelist="authmysql"
   authmodulelistorig="authmysql"
   daemons=10
   # vi authmysqlrc
   修改/etc/authmysqlrc 為以下內容,其中501,501 為postfix 用戶的UID和GID。
   MYSQL_SERVER localhost
   MYSQL_PORT 3306                   (指定你的mysql監聽的埠,這裡使用默認的3306)
   MYSQL_USERNAME  extmail      (這時為後文要用的資料庫的所有者的用戶名)
   MYSQL_PASSWORD extmail        (密碼)
   MYSQL_SOCKET  /tmp/mysql.sock
   MYSQL_DATABASE  extmail
   MYSQL_USER_TABLE  mailbox
   MYSQL_CRYPT_PWFIELD  password
   MYSQL_UID_FIELD  '501'  501為postfix用戶uid
   MYSQL_GID_FIELD  '501'  501為postfix組gid
   MYSQL_LOGIN_FIELD  username
   MYSQL_HOME_FIELD  concat('/var/mailbox/',homedir)
   MYSQL_NAME_FIELD  name
   MYSQL_MAILDIR_FIELD  concat('/var/mailbox/',maildir)
  3.5.3設置開機自啟動
   # cp /usr/local/src/postfix/courier-authlib-0.62.4/courier-authlib.sysvinit  
                      /etc/init.d/courier-authlib
   # chmod 755 /etc/init.d/courier-authlib
   # chkconfig --add courier-authlib
   # chkconfig --level 345  courier-authlib on
3.6 安裝cyrus-sasl
  3.6.1 編譯安裝
   # tar -zxvf cyrus-sasl-2.1.18.tar.gz
   # cd cyrus-sasl-2.1.18
   # ./configure --prefix=/usr/local/sasl2
   --disable-gssapi --disable-anon  --disable-digest
   --enable-plain  --enable-login  
   --enable-sql  --with-mysql=/usr/local/mysql/
   --with-mysql-includes=/usr/local/mysql/include/mysql/
   --with-mysql-libs=/usr/local/mysql/lib/mysql/ -      
   --with-authdaemond=/usr/local/courier-authlib/var/spool/authdaemon/socket
   #一定要加--enable-login,因為SASL2默認不支持login這種驗證方式,而OUTLOOK是通過login來進行SMTP驗證的。
   #make
   #我在這裡執行報錯
   auth_getpwent.c:48:20: des.h: No such file or directory
    make: *** Error 1
    make: Leaving directory `/usr/local/src/postfix/cyrus-sasl-2.1.18/saslauthd'
    make: *** Error 2
    make: Leaving directory `/usr/local/src/postfix/cyrus-sasl-2.1.18/saslauthd'
    make: *** Error 1
    make: Leaving directory `/usr/local/src/postfix/cyrus-sasl-2.1.18'
    make: *** Error 2
   解決辦法:將安裝目錄下mac/libdes/public/des.h拷貝到安裝根目錄
   # cp mac/libdes/public/des.h .
   #make install
  3.6.2 配置sasl
   創建運行時需要的目錄並調試啟動
   # mkdir -pv /var/state/saslauthd
   在/var/目錄下建一個目錄給saslauthd進程存在臨時數據。假如沒有這些目錄,運行saslauthd時,會提示出錯。
接著為確保CYRUS-SASL2函數庫知道怎樣驗證所收來的SASL認證請求,必須創建一個SASL的配置文檔。配置文檔名為smtpd.conf位於/usr/local/sasl2/lib/sasl2這個目錄,在該文檔中您定義您希望使用的認證資料庫方法,以下這個例子使用saslauthd來驗證認證請求.
   # vi /usr/local/sasl2/lib/sasl2/smtpd.conf
   添加以下內容
   pwcheck_method: saslauthd
   mech_list: PLAIN LOGIN   
  3.6.3啟動並測試
   #/usr/local/sasl2/sbin/saslauthd  -a  shadow  pam  -d
   #/usr/local/sasl2/sbin/saslauthd -a shadow pam
   #/usr/local/sasl2/sbin/testsaslauthd -u root -p root(用戶密碼)
   0: OK "Success."
   假如出現以上信息,就說明saslauthd正常運行了。testsaslauthd程式默認是沒有編譯的,您需要在源碼目錄樹的saslauthd子目錄中運行# make testsaslauthd命令生成。
  3.6.4添加連接庫
   postfix編譯安裝會用到,否則報錯.
   #echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf
   #echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf
   # ldconfig
  3.6.5添加庫連接到/usr/lib
   因為postfix會到/usr/lib目錄下去找SASL2庫,而我們是把程式安裝在/usr/local/sasl2中,所以我們要在/usr/lib目錄下做一個鏈接:
   # ln -s /usr/local/sasl2/lib/sasl2/ /usr/lib/sasl2
   這個必須連接放到/usr/lib下,否則為postfix開啟基於cyrus-sasl的認證功能時,
   Ok,完畢~
3.7 安裝postfix
  3.7.1 編譯安裝
   # tar -zxvf postfix-2.6.0.tar.gz
   # cd postfix-2.6.0
   # make -f Makefile makefiles
   'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql
   -DUSE_SASL_AUTH  -DUSE_CYRUS_SASL  -I/usr/local/sasl2/include/sasl'
   'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib  -lsasl2'
   #這裡注意啦! -lmysqlclient -lz –lm這三個開頭是L的小寫,不是i的大寫,這個錯誤折騰了2小時…
   #make
   #make install
   Install_root: [/]/
   tempdir: /tmp
   config_directory: /etc/postfix
   daemon_directory: /usr/local/postfix/libexec
   command_directory: /usr/local/postfix/sbin
   queue_directory: /var/spool/postfix
   sendmail_path: /usr/sbin
   newaliases_path: /usr/bin/newaliases
   mailq_path: /usr/bin/mailq
   mail_owner: postfix
   setgid_group:   postdrop
   html_directory: no
   manpages: /usr/local/postfix/man   
   readme_directory: no
   按以上選項安裝postfix.
  3.7.2 配置potfix
   生成別名二進位文件,這個步驟如果忽略,會造成postfix效率極低:
    #  newaliases
   #這個必須執行,否則後面會報錯fatal: open database /etc/aliases.db: No such file or directory
   #cd /usr/local/postfix
   #vi /etc/postfix/main.cf
   修改以下幾項為您需要的配置
   myhostname = mail.drvial.com
   myorigin = drvial.com
   mydomain = drvial.com
   mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
   mynetworks = 192.168.2.0/24, 127.0.0.0/8
   inet_interfaces = all
   上述配置中,需要特別注意的是mydomain和myhostname,這2個項的值不要設置成一樣,否則postfix將不能正確啟動,虛擬郵箱不可用。
   說明:
   myorigin參數用來指明發件人所在的域名;
   mydestination參數指定postfix接收郵件時收件人的域名,即您的postfix系統要接收到哪個域名的郵件;
   myhostname 參數指定運行postfix郵件系統的主機的主機名,默認情況下,其值被設定為本地機器名;
   mydomain參數指定您的域名,默認情況下,postfix將myhostname的第一部分刪除而作為mydomain的值;
   mynetworks 參數指定你所在的網路的網路地址,postfix系統根據其值來區別用戶是遠程的還是本地的,如果是本地網路用戶則允許其訪問;
   inet_interfaces 參數指定postfix系統監聽的網路介面;
   注意:
   #在postfix的配置文件中,參數行和註釋行是不能處在同一行中的;
   #任何一個參數的值都不需要加引號,否則,引號將會被當作參數值的一部分來使用;
   #每修改參數及其值后執行 postfix reload 即可令其生效;但若修改了inet_interfaces,則需重新啟動postfix;
   #如果一個參數的值有多個,可以將它們放在不同的行中,只需要在其後的每個行前多置一個空格即可;postfix會把第一個字元為空格或tab的文本行視為上一行的延續;
  3.7.3設置開機自啟動
    #echo 」/usr/local/postfix/sbin/postfix  start」 >>/etc/rc.local
    啟動postfix
    #/usr/local/postfix/sbin/postfix  start
  3.7.4 可能的postfix啟動故障
    1, fatal: file /etc/postfix/main.cf: parameter mail_owner: unknown user name value: postfix mynetworks
       =127.0.0.0/8,10.1.1.0/24
      解決方法inte--inteface=all
    2, fatal: file /etc/postfix/main.cf: parameter mail_owner: unknown user name value: postfix myhostname
       = mail.test.com mydomain = test.com myorigin = test.com inet_interfaces = all
      解決方法:postconf -e mail_owner=postfix
    3, fatal: open database /etc/aliases.db: No such file or directory
      解決方法 執行:newaliase
    4, warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
      找到/etc/postfix/main.cf文件中的alias_maps = hash:/etc/aliases, nis:mail.aliases 去掉其後即可.
  3.7.5連接postfix,驗正服務啟動狀況:
     # telnet localhost 25
     Trying 127.0.0.1...
     Connected to mail.drvial.com (127.0.0.1).
     Escape character is '^]'.
     220 mail.drvial.com ESMTP Postfix
     ehlo mail.drvial.com
     250- mail.drvial.com
     250-PIPELINING
     250-SIZE 10240000
     250-VRFY
     250-ETRN
     250-ENHANCEDSTATUSCODES
     250-8BITMIME
     250 DSN
     mail from:root@ drvial.com
     250 2.1.0 Ok
     rcpt to:drvial@ drvial.com
     250 2.1.5 Ok
     data
     354 End data with <CR><LF>.<CR><LF>
     subject:Mail test!
     Mail test!!!
     .
     250 2.0.0 Ok: queued as AB94A1A561
     quit
     221 2.0.0 Bye
     Connection closed by foreign host.
     切換到redhat用戶進行收信:
     # su – drvial
     $ mail
     Mail version 8.1 6/6/93.  Type ? for help.
     "/var/spool/mail/drvial": 1 message 1 new
      >N  1 root@drvial.com
       Wed Sep  5 10:59  15/488   "Mail test!"
      &
  3.7.6 為postfix開啟基於cyrus-sasl的認證功能
     使用以下命令驗正postfix是否支持cyrus風格的sasl認證,如果您的輸出為以下結果,則是支持的:
     #/usr/local/postfix/sbin/postconf  -a
     cyrus
     dovecot
     #vi /etc/postfix/main.cf
     在最後添加以下內容:
############################CYRUS-SASL############################
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
     #vi /usr/local/lib/sasl2/smtpd.conf
     添加如下內容:
     pwcheck_method: saslauthd
     mech_list: PLAIN LOGIN
     讓postfix重新載入配置文件
     #/usr/local/postfix/sbin/postfix reload
     #telnet localhost 25
     Trying 127.0.0.1...
     Connected to mail.drvial.com (127.0.0.1).
     Escape character is '^]'.
     220 Welcome to our mail.drvial.com ESMTP,Warning: Version not Available!
     ehlo mail.drvial.com
     250- mail.drvial.com
     250-PIPELINING
     250-SIZE 10240000
     250-VRFY
     250-ETRN
     250-AUTH PLAIN LOGIN
     250-AUTH=PLAIN LOGIN               (請確保您的輸出以類似兩行)
     250-ENHANCEDSTATUSCODES
     250-8BITMIME
     250 DSN
  3.7.7 配置postfix以支持虛擬域和虛擬用戶
     1、編輯/etc/postfix/main.cf,添加如下內容:
########################Virtual Mailbox Settings########################
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:501  #501為你添加的postfix用戶uid
virtual_gid_maps = static:501  #501為你添加的postfix組gid
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
要注意的地方是 virtual_uid_maps及virtual_gid_maps的值,它是postfix用戶的uid和postfix組的gid,與前面的文件/usr/local/authlib/etc/authlib/authmysqlrc的"MYSQL_UID_FIELD""MYSQL_GID_FIELD"一定要保持一致,
##########################QUOTA Settings########################
message_size_limit = 14336000
virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota, please Tidy your mailbox and try again later.
virtual_overquota_bounce = yes
     2、添加為支持虛擬域和虛擬用戶所用到的配置文件,以下4個配置文件是不存在的,需要創建.
編輯/etc/postfix/mysql_virtual_alias_maps.cf ,添加如下內容:
     user = extmail
     password = extmail
     hosts = localhost
     dbname = extmail
     table = alias
     select_field = goto
     where_field = address
編輯/etc/postfix/mysql_virtual_domains_maps.cf ,添加如下內容:
     user = extmail
     password = extmail
     hosts = localhost
     dbname = extmail
     table = domain
     select_field = description
     where_field = domain
編輯/etc/postfix/mysql_virtual_mailbox_limit_maps.cf ,添加如下內容:
     user = extmail
     password = extmail
     hosts = localhost
     dbname = extmail
     table = mailbox
     select_field = quota
     where_field = username
編輯/etc/postfix/mysql_virtual_mailbox_maps.cf ,添加如下內容:
     user = extmail
     password = extmail
     hosts = localhost
     dbname = extmail
     table = mailbox
     select_field = maildir
     where_field = username
   說明:
1、這裡用到的資料庫及用戶的建立可以後文中的extmail說明部分來實現,您可以參照那一部分來理解這裡指定的資料庫及其用戶名等;
2、以上新建文件亦可以從extman安裝文件中獲得,您也可以由此不用手動輸入;
3、虛擬用戶郵箱目錄我這裡沿用了/var/mailbox,你可以指定為別的目錄,比如常見到的/var/spool/mail,或者/home/domains等;但如果這裡做了修改,請在後文中用到時作了相應的修改;
《解決方案》

3.8 安裝Courier-IMAP
  3.8.1 編譯安裝
    # tar -jxvf courier-imap-4.5.1.tar.bz2
    # cd courier-imap-4.5.1
    # ./configure  --prefix=/usr/local/courier-imap
    --enable-unicode --disable-root-check --with-trashquota --without-ipv6
    CPPFLAGS='-I/usr/local/courier-authlib/include'
LDFLAGS='-L/usr/local/courier-authlib/lib/courier-authlib'  
    COURIERAUTHCONFIG='/usr/local/courier-authlib/bin/courierauthconfig     
# make
# make install
  
  3.8.2 配置imap
    # cd /usr/local/courier-imap/
    # cp ./etc/imapd.dist  ./etc/imapd
    # cp ./etc/imapd-ssl.dist  ./etc/imapd-ssl
    # cp ./etc/pop3d.dist  ./etc/pop3d
    # cp ./etc/pop3d-ssl.dist  ./etc/pop3d-ssl
    配置Courier-IMAP,為用戶提供pop3服務:
    # vi ./etc/pop3d
    POP3DSTART=YES
    註:如果你想為用戶提供IMAP服務,則需在"/usr/local/courier-imap/etc/imapd"文件中設置"IMAPDSTART=yes";其它類同;
  3.8.3 設置開機啟動
    #cd /usr/local/src/postfix/courier-imap-4.5.1/
    #cp courier-imap.sysvinit  /etc/rc.d/init.d/courier-imapd
#chmod 755 /etc/rc.d/init.d/courier-imapd
    #chkconfig --add courier-imapd
    #chkconfig --level 2345 courier-imapd on
    #service courier-imapd start
  3.8.4新建虛擬用戶郵箱所在的目錄
    新建虛擬用戶郵箱所在的目錄,並將其許可權賦予postfix用戶:
    #mkdir –pv /var/mailbox
    #chown –R postfix /var/mailbox
    接下來重新配置SMTP 認證,編輯 /usr/local/lib/sasl2/smtpd.conf:
    #vi /usr/lib/sasl2/smtpd.conf
    確保其為以下內容:
    pwcheck_method: authdaemond
    log_level: 3
    mech_list:PLAIN LOGIN
    authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
3.9 安裝Extmail
  3.9.1 解壓安裝
    # tar -zxvf extmail.tar.gz
    # cp -r extmail-1.0.5/  /usr/local/apache/htdocs/extmail
    # cd /usr/local/apache/htdocs/extmail
    # cp webmail.cf.default  webmail.cf
    # cd html/
    # cp -r default  ../
    # cp -r images  ../
    # cp  index.html  ../
  3.9.2 修改主配置文件
    # vi webmail.cf
    部分修改選項的說明:
    SYS_CONFIG = /usr/local/apache/htdocs/extmail/
    SYS_LANGDIR = /usr/local/apache/htdocs/extmail/lang
    SYS_TEMPLDIR = /usr/local/apache/htdocs/extmail/html
    SYS_MESSAGE_SIZE_LIMIT = 5242880    #用戶可以發送的最大郵件
    SYS_USER_LANG = en_US
    語言選項,可改作:
    SYS_USER_LANG = zh_CN
    SYS_MAILDIR_BASE = /home/domains
    此處即為您在前文所設置的用戶郵件的存放目錄,可改作:
    SYS_MAILDIR_BASE = /var/mailbox
    SYS_MYSQL_USER = db_user
    SYS_MYSQL_PASS = db_pass
    以上兩句句用來設置連接資料庫伺服器所使用用戶名、密碼和郵件伺服器用到的資料庫,這裡修改為:
    SYS_MYSQL_USER = extmail
    SYS_MYSQL_PASS = extmail
    SYS_MYSQL_HOST = localhost
    指明資料庫伺服器主機名,這裡默認即可
    SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
    連接資料庫的sock文件位置,這裡修改為:
    SYS_MYSQL_SOCKET = /tmp/mysql.sock
    SYS_MYSQL_TABLE = mailbox
    SYS_MYSQL_ATTR_USERNAME = username
    SYS_MYSQL_ATTR_DOMAIN = domain
    SYS_MYSQL_ATTR_PASSWD = password
    以上用來指定驗正用戶登錄里所用到的表,以及用戶名、域名和用戶密碼分別對應的表中列的名稱;這裡默認即可
    SYS_AUTHLIB_SOCKET = /var/spool/authdaemon/socket
    此句用來指明authdaemo socket文件的位置,這裡修改為:
    SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket
  3.9.3 apache相關配置
    # vi /etc/httpd/httpd.conf
    在這個<Directory "/usr/local/apache/htdocs">…..省略</Directory>后添加
    <Directory "usr/local/apache/htdocs/extmail/cgi">
         Options Indexes FollowSymLinks +ExecCGI
         AllowOverride None
         Order allow,deny
         Allow from all
    </Directory>
    <Directory "usr/local/apache/htdocs/extman/cgi">
        Options Indexes FollowSymLinks +ExecCGI
        AllowOverride None
        Order allow,deny
       Allow from all
     </Directory>
     在這個模塊里添加index.cgi,如下:
     <IfModule dir_module>
       DirectoryIndex index.html index.php index.cgi
       </IfModule>
      在這個<IfModule mime_module>模塊里添加如下:
      AddHandler cgi-script .cgi
3.10安裝Unix-syslog和DBI-1.607,DBD-Mysql
     Extmail依賴unix-syslog,DBD-mysql.DBD-Mysql需要DBI包.
  3.10.1 安裝Unix-syslog
     # tar -zxvf Unix-Syslog-0.100.tar.gz
     # cd Unix-Syslog-0.100
     #perl Makefile.PL
     #make
     ## make install
  3.10.2 安裝DBI-1.607,DBD-Mysql
     # tar –zxvf  DBI-1.607.tar.gz
     # cd DBI-1.607
     # perl Makefile.PL
     #make
     #make install
     # tar –zxvf   DBD-mysql-3.0002.tar.gz
     # cd DBD-mysql-3.0002
     # perl Makefile.PL
     #make
     #make install
     好了,到此為止,您的Webmail已經可以使用了,可以在瀏覽器中輸入指定的虛擬主機的名稱進行訪問,如下:
     http://localhost/extmail 或者 http://ip/extmail
3.11安裝Extman
  3.11.1 解壓安裝
    # tar -zxvf extman-1.0.0.tar.gz
    # cp -r extman-1.0.0 /usr/local/apache/htdocs/extman
    # cd /usr/local/apache/htdocs/extman
    # mkdir /var/tmp/extman
    # chown postfix.postfix /var/tmp/extman
    # chown -R  postfix.postfix cgi
    # cd html/
    # cp -r default  ../
    # cp -r images  ../
    # cp  index.html  ../
  3.11.2 配置Extman
    #vi webman.cf
    修改如下配置
    SYS_CONFIG = /usr/local/apache/htdocs/extman/
    SYS_LANGDIR = /usr/local/apache/htdocs/extman/lang
    SYS_TEMPLDIR = /usr/local/apache/htdocs/extman/html
    SYS_MAILDIR_BASE = /home/domains
    此處即為您在前文所設置的用戶郵件的存放目錄,可改作:
    SYS_MAILDIR_BASE = /var/mailbox/
    SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
    此處修改為:
    SYS_MYSQL_SOCKET = /tmp/mysql.sock
    SYS_SESS_DIR = /var/tmp/extman/
    SYS_CAPTCHA_ON = 0  #
  3.11.3 建立資料庫
    使用extman源碼目錄下docs目錄中的extmail.sql和init.sql建立資料庫:
    # cd docs/
    # mysql -u root -p <extmail.sql
    Enter password:
    # mysql -u root -p <init.sql
    Enter password:
    在瀏覽器中輸入以下連接進行訪問:
    http://localhost/extman 或者 http://ip/extman
    進入郵件伺服器的後台,添加域與添加用戶郵箱。默認管理帳號為:root@extmail.org  密碼為:extmail*123*。我這裡添加了一個 drvial.com 域和一個用戶郵箱:drvial@drvial.com.至於開通郵件伺服器自動註冊郵箱服務,只需要編輯該域,將「允許自由註冊郵箱」前面打上勾即可。
  3.11.3校驗碼和圖形日誌(這兩個我還沒弄呢~~)
    可以配置extman/webman.cf中SYS_CAPTCHA_ON = 0  #取消校驗碼,1為使用校驗碼,
    (1) 如果您安裝后無法正常顯示校驗碼,安裝perl-GD模塊會解決這個問題。如果想簡單,您可以到以下地址下載適合您的平台的rpm包,安裝即可:  http://dries.ulyssis.org/rpm/packages/perl-GD/info.html
    (2) extman-0.2.2自帶了圖形化顯示日誌的功能;此功能需要rrdtool的支持,您需要安裝此些模塊才可能正常顯示圖形日誌。
接下來安裝圖形日誌的運行所需要的軟體包Time::HiRes、File::Tail和rrdtool,其中前兩個包您可以去http://search.cpan.org搜索並下載獲得,后一個包您可以到 http://oss.oetiker.ch/rrdtool/pub/?M=D下載獲得; 注意安裝順序不能改換。
《解決方案》

四 測試系統
4.1測試smtp
     通過以下命令獲得 drvial@drvial.com的用戶名和密碼的BASE64編碼
     獲得用戶名BASE64編碼
     # perl -e 'use MIME::Base64;print encode_base64("drvial\@drvial.com")'
     ZHJ2aWFsQGRydmlhbC5jb20=
     獲得密碼BASE64編碼
     # perl -e 'use MIME::Base64;print encode_base64("drvial")'
     ZHJ2aWFs
     # telnet localhost 25
     Trying 127.0.0.1...
     Connected to localhost.localdomain (127.0.0.1).
     Escape character is '^]'.
     220 Welcome to our mail.drvial.com ESMTP,Warning:Version not Available!
     ehlo mail.drvial.com
     250-mail.drvial.com
     250-PIPELINING
     250-SIZE 14336000
     250-VRFY
     250-ETRN
     250-AUTH LOGIN PLAIN
     250-AUTH=LOGIN PLAIN
     250-ENHANCEDSTATUSCODES
     250-8BITMIME
     250 DSN
     auth login
     334 VXNlcm5hbWU6
     ZHJ2aWFsQGRydmlhbC5jb20==
     334 UGFzc3dvcmQ6
     ZHJ2aWFs==
     235 2.7.0 Authentication successful   #正常
     quit
     221 2.0.0 Bye
     Connection closed by foreign host.
4.2測試pop3
     # telnet localhost 110
     Trying 127.0.0.1...
     Connected to localhost.localdomain (127.0.0.1).
     Escape character is '^]'.
     +OK Hello there.
     user drvial@drvial.com
     +OK Password required.
     pass drvial
     +OK logged in.   #正常
     quit
     +OK Bye-bye.
     Connection closed by foreign host.
4.3測試authlib
     # /usr/local/courier-authlib/sbin/authtest -s login drvial@drvial.com drvial
     Authentication succeeded.
     Authenticated: drvial@drvial.com  (uid 501, gid 501)
     Home Directory: /var/mailbox/drvial.com/drvial
           Maildir: /var/mailbox/drvial.com/drvial/Maildir/
             Quota: (none)
     Encrypted Password: $1$uAYUSAHN$mTVYsRgWhXpzfHp9Dqld3/
     Cleartext Password: drvial
           Options: (none)
     如上顯示正常
4.4測試sasl
     # /usr/local/sasl2/sbin/testsaslauthd  -u root -p root
     0: OK "Success."  
五 系統排錯
     錯誤總是無處不在,因為每一步都需要輸入很多參數,編輯很多配置,很仔細很仔細了,大部分錯誤的產生還是因為參數寫錯或者配置寫錯造成的.為了出現錯誤后,可以排查.需要學會看日誌,需要學會google.
5.1查看日誌排錯
     Mail的日誌是/var/log/maillog
     系統日誌是/var/log/messages
     為了獲得更詳細的日誌將配置authdaemonrc
     # vi /usr/local/courier-authlib/etc/authlib/authdaemonrc
     DEBUG_LOGIN=2  設置此項為2,原來默認是0.當系統無錯誤時在更改為0.
5.2可能的錯誤及解決辦法
     1.warning: SASL authentication failure: cannot connect to Courier authdaemond: Permission denied
       解決方法:檢查 authdaemond的socket所在目錄及其父目錄的屬性是否對smtpd可讀。如果不可讀則出現這個問
                 題(permission的問題)。
     2.warning: SASL authentication failure: cannot connect to Courier authdaemond: No such file or directory
       解決方法:檢查/usr/local/lib/sasl2/smtpd.conf,看看是否有多寫一個空格,一般空格很難直觀的發現.
     3,查看 /var/log/maillog ,報如下錯誤:
       Sep 17 16:04:56 redhat pop3d: chdir Maildir: No such file or directory
       Sep 17 16:04:57 redhat pop3d: Connection, ip=
       Sep 17 16:04:57 redhat pop3d: chdir Maildir: No such file or directory
       解決方法:authmysqlrc 文件里 MYSQL_MAILDIR_FIELD 欄位有空格。
     4,warning: do not list domain test.com in BOTH mydestination and virtual_mailbox_domains
       解決方法:將/etc/postfix/main.cf文件內mydestination設置為空即可,或完全註釋也行. mydomain和
                myhostname,這2個項的值不要設置成一樣.
     5,fatal: file /etc/postfix/main.cf: parameter mail_owner: unknown user name value:
       postfix mynetworks =127.0.0.0/8,10.1.1.0/24
       解決方法:postconf -e mail_owner=postfix
     6,fatal: file /etc/postfix/main.cf: parameter mail_owner: unknown user name value: postfix myhostname =
       mail.test.com mydomain = test.com myorigin = test.com inet_interfaces = all
       解決方法:配置/etc/postfix/main.cf 中的inte--inteface=all
     7, fatal: open database /etc/aliases.db: No such file or directory
       解決方法:執行:newaliase
     8,warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
       解決方法:找到/etc/postfix/main.cf文件中的alias_maps = hash:/etc/aliases, nis:mail.aliases 去掉其後即可
     9, warning: xsasl_cyrus_server_get_mechanism_list: no applicable SASL mechanisms
        fatal: no SASL authentication mechanisms
        warning: process /usr/libexec/postfix/smtpd pid 16829
       解決方法:
       # ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
參考資料
       1, RHEL4上安裝基於postfix的全功能郵件伺服器(全部使用目前最新源碼包構建)
       http://bbs2.chinaunix.net/viewthread.php?tid=987344&extra=page%3D1%26amp%3Bfilter%3Ddigest
       2, Postfix 電子郵件系統精要
         http://www.51cto.com/art/200710/57530.htm
       3, <POSTFIX權威指南>
《解決方案》

對於小的應用可以使用的性能也很好的
《解決方案》

太經典了,收藏

贊一下樓主的毅力,我開始搞postfix也快2個星期了,其中也因為解決了一些小問題,沾沾自喜,可是到了最後,還是到了最後卡住

希望這次能借樓主的東風,馬到成功:em02:

[ 本帖最後由 mzq8293 於 2009-7-25 15:26 編輯 ]
《解決方案》

extmail uid:gid = 501:501
postfix uid:gid = 502:502

在 /usr/local/courier-authlib/etc/authlib/authmysqlrc
MYSQL_UID_FIELD  '501'  
MYSQL_GID_FIELD  '501'

在 /etc/postfix/main.cf
virtual_uid_maps = static:501  
uid virtual_gid_maps = static:501  

在使用extmail發郵件的時候,查看日誌得到以下信息
Aug 12 06:36:00 localhost postfix/smtpd: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
Aug 12 06:36:00 localhost postfix/smtpd: connect from localhost.localdomain
Aug 12 06:36:00 localhost postfix/smtpd: 3E9041C0183: client=localhost.localdomain
Aug 12 06:36:00 localhost postfix/cleanup: 3E9041C0183: message-id=<20090811223600.3E9041C0183@mail.mazq.com>
Aug 12 06:36:00 localhost postfix/qmgr: 3E9041C0183: from=<test1@mazq.com>, size=649, nrcpt=1 (queue active)
Aug 12 06:36:00 localhost postfix/virtual: warning: maildir access problem for UID/GID=501/501: create maildir file /var/mailbox/mazq.com/test1/Maildir/tmp/1250030160.P2629.localhost.localdomain: Permission denied
Aug 12 06:36:00 localhost postfix/virtual: warning: perhaps you need to create the maildirs in advance
Aug 12 06:36:00 localhost postfix/smtpd: disconnect from localhost.localdomain
Aug 12 06:36:00 localhost postfix/virtual: 3E9041C0183: to=<test1@mazq.com>, relay=virtual, delay=0.16, delays=0.1/0.02/0/0.04, dsn=4.2.0, status=deferred (maildir delivery failed: create maildir file /var/mailbox/mazq.com/test1/Maildir/tmp/1250030160.P2629.localhost.localdomain: Permission denied)

請樓主給看看是怎麼回事
《解決方案》

正好想從sendmail換成postfix了。
借鑒了。
樓主辛苦。
《解決方案》

回復 #7 mzq8293 的帖子

mkdir –pv /var/mailbox
chown –R postfix /var/mailbox
:mrgreen: 看看/var/mailbox目錄的許可權
《解決方案》

頂啊。。這兩天也在弄psotfix,不過好像有點不成功,現在看看你的明白很多。做的不錯。。頂一下。。

[火星人 ] 新手的Centos5.2+postfix安裝配置,請大家校驗.已經有1462次圍觀

http://coctec.com/docs/service/show-post-18406.html