Sendmail 是目前在互聯網上應用得最為廣泛的SMTP 服務器之一,但在一般情況下,它并不能獨立使用,還需要與UNIX/LINUX操作系統自身的mail 應用結合。而且每增加一個郵件用戶,實際上就是增加一個系統用戶。這樣做,不僅使用不方便,在用戶很多時,還會大大增加系統的開銷,影響服務器的性能;同時,由于郵件用戶可能來自整個互聯網的四面八方,系統用戶的口令在網上傳送,也增加了系統的危險性。這里介紹一種可以使郵件用戶與系統用戶分開的方法,供參考。
一. 系統環境
以 Linux 操作系統(Redhat 5.2) 為例
二. 安裝 mh軟件包
1. 下載
可在中國自由軟件庫()站點下載mh-6.8.4-2.tar.gz 軟件包。
2. 編譯
在mh軟件包已下載完畢后,即可進行編譯,步驟如下:
$ tar -zxvf mh-6_8_4-2_tar.gz
$ cd mh-6.8.4
$ cd conf
$ vi MH # 調整或增加部分參數如下(其余參數用缺省值即可):
bin /usr/local/bin # 執行命令的安裝目錄
etc /usr/local/etc/mh # 系統調用程序的安裝目錄
mandir /usr/local/man # 幫助文件的安裝目錄
ccoptions # 去掉 "-traditional",其余不變
ldoptlibs -lcrypt
mts sendmail/smtp # 用sendmail投遞郵件
pop on # 支持POP服務
popdir /usr/local/lib/mh #popd 的安裝目錄
options POPSERVICE=@#"pop-3"@#
# pop-3應與/etc/services 文件110/tcp端口定義的服務名一致
options POSIX
options BSD42
options BSD43
(各參數的意義及用法,可參考 conf/READ-ME文件)
$ vi ./config/mtstailor # 確定 sendmail參數對應sendmail的可執行文件,如:
sendmail: /usr/sbin/sendmail
$ vi ./config/mtstailor # 確定 sendmail參數對應sendmail的可執行文件,
如:sendmail: /usr/sbin/sendmail
$ make
$ ./mhconfig MH
$ cd ../
$ make
3. 安裝
$su
# mkdir -p /usr/local/bin /usr/local/lib/mh
/usr/local/etc/mh /usr/local/man #生成字安裝目錄
# make inst-all # 完全安裝
三. 安裝 sendmail軟件包
1. 下載
可在中國自由軟件庫()站點下載sendmail.8.11.0.tar.gz 軟件包。
2. 編譯
在sendmail軟件包已下載完畢后,即可進行編譯,步驟如下:
$ tar -zxvf sendmail.8.11.0.tar.gz
$ cd sendmail-8.11.0
$ cd sendmail
$ ./Build # 編譯 sendmail
3. 安裝
$ ./Build install
4. 配置
$ cd ../../cf/ostype
$ vi linux.m4 #增加一行:
define(`POP_MAILER_PATH@#, `/usr/local/etc/mh/spop@#)
...
$ cd ../cf/
$ vi generic-linux.mc #增加一行:
MAILER(pop)dnl
$ m4 ../m4/cf.m4 ./genric-linux.mc > sendmail.cf
$ su
# cp ./sendmail.cf /etc/mail
# chmod g-w /etc/mail/sendmail.cf
# cp /etc/sendmail.cw /etc/mail/local-host-names #存放該服務器的域名,
四. 調試
假設郵件服務器的域名為:test.com,現在要新開一個郵箱:,并進行測試:
# /usr/sbin/useradd -d /home/pop -m pop # 生成pop 用戶
# passwd -l pop #鎖定pop用戶
# chmod 755 /home/pop
注: /home/pop 為pop 系統用戶的工作目錄,該目錄將用來存放郵件用戶數據庫和用戶的所有郵件
# su - pop
$ echo "test::test.box:::test@test.com::::" >> POP
# POP為郵箱的數據庫文件,貯存全部的郵箱信息。此操作為增加一個用戶test,其電子郵件地址為:。test.box 為該用戶郵箱文件名
$ /usr/local/etc/mh/popwrd test # 為test 郵件用戶設置口令
New password:
Retype new password:
$ exit
# /usr/local/etc/mh/popaka >> /etc/mail/aliases
# chmod g-w /etc/mail/aliases
# newaliases
# /usr/lib/sendmail -bd -q30m #啟動sendmail 服務進程
# /usr/local/lib/mh/popd #啟動pop服務進程
以下可使用Microsoft Outlookup Express等工具對 郵箱進行收發郵件測試,以上對這一能使郵件用戶和操作系統用戶區分開的方法進行了簡單的介紹,關于這種組合方法,在使用時還有很多的技術細節,可參考軟件包的有關文檔資料,進行參數的優化。