自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

sendmail下設(shè)定郵箱大小

運維 系統(tǒng)運維
在Linux或者UNIX平臺下,如何設(shè)定sendmail郵箱的大小呢?由于現(xiàn)在垃圾郵件或者長時間不讀取郵件而造成的大面積磁盤空間的浪費,這一系列的問題該如何處理呢?

  目前,在Linux/Unix平臺上,Sendmail因成為缺省安裝的郵件服務器而得到非常廣泛的應用。但是Sendmail本身并不具有限定用戶郵箱大小的功能,所以,如果某些用戶長時間不取信或設(shè)定了保留郵件副本,其信件將在服務器上不斷堆積,以致郵箱越來越大,占用大量的硬盤空間,很多網(wǎng)絡管理員對此都很有意見。這里介紹一種簡單實用的方法,通過它, 我們可以很方便靈活地對用戶郵箱的大小進行設(shè)定。

一、基本思路

  先設(shè)定一個用戶郵箱大小的門限值;然后定期啟動一個進程,檢查每一個用戶郵箱文件的大小,將所有超過這一限值的郵箱文件名臨時寫進某一特定的文件中; 再讀取該文件,將它寫進Sendmail 的黑名單(blacklist_recipients) 中,從而使郵件服務器拒收該用戶的新郵件,直到下次檢查時該郵箱大小已小于設(shè)定的門限值為止。

二、運行環(huán)境

  我們以Solaris 2.7操作系統(tǒng)為例進行說明,其他Unix(或Linux)系統(tǒng)可參照來做。

  本文以Sendmail 8.11.3為例,若無該版本的Sendmail運行軟件,可到http://freesoft.cei.gov.cn或 http://www.sendmail.org站點下載。

三、具體操作

  1. 下載編譯

  在Sendmail軟件包已下載到當前目錄后即可進行編譯,操作步驟如下。

  dc sendmail.8.11.3.tar.gz | tar -xf - (Gzip 是一個壓縮/解壓縮的工具,相當于 Windows平臺上的WinZip,在網(wǎng)上能很容易地找到并下載)

  sendmail-8.11.3/sendmail

  /Build

  (編譯Sendmail )

  2. 安裝

  1.   # ./Build install  

  (用超級用戶身份安裝)

  3. 生成配置文件

  1.   # cd ../cf/domain  
  2.  
  3.   # vi generic.m4 

  此時,在文件的末尾增加如下兩行內(nèi)容。

  FEATURE('access_db','dbm /etc/mail/access')dnl

  FEATURE('blacklist_ recipients')dnl

  然后,我們可以按著輸入以下內(nèi)容。

  1.   # cd ../cf  
  2.  
  3.   # m4 ../m4/cf.m4 ./generic-solaris2.mc > ./sendmail.cf  
  4.  
  5.   # cp ./sendmail.cf /etc/mail/  
  6.  

  4.生成 access 文件及郵件服務器名稱的參數(shù)文件

  1.   # cd /etc/mail  
  2.  
  3.   # makemap dbm access < /dev/null  
  4.  
  5.   # vi local-host-names  
  6.  

  (該文件是一個文本文件,內(nèi)容為本地郵件服務器的域名和別名,它們之間要用回車分隔。詳見Readme文件的有關(guān)介紹)

  5. 啟動Sendmail

  1.   # /usr/lib/sendmail -bd -q30m  

  6. 編緝限制郵箱大小的程序

  用sh命令編緝一個限制郵箱大小的程序,然后用操作系統(tǒng)的定時執(zhí)行功能crontab設(shè)定其執(zhí)行的頻率,內(nèi)容如下。

  1.   # vi /etc/mail/limit_mailbox.sh  
  2.  
  3.   # chmod u+x /etc/mail/limit_mailbox.sh  
  4.  
  5.   # crontab -e  
  6.  

  接著,我們可以輸入以下內(nèi)容。

  0 6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 * * * /etc/mail/limit_mailbox.sh 10

  它表示在每天6:00~20:00間,每隔1小時啟動一次,檢查郵箱大小的sh命令。用戶也可根據(jù)實際情況進行調(diào)整。“10”表示郵箱大小的門限值為10MB。

四、附錄limit_mailbox.sh 源代碼

 

  1.  #!/usr/bin/ksh  
  2.  
  3.   # search the mailbox larger than MAXSIZE , then set this mailbox full and reject new mails  
  4.  
  5.   error() {  
  6.  
  7.   echo " "  
  8.  
  9.   exit 1  
  10.  
  11.   }  
  12.  

  BIN=/usr/bin

  MAIL=/etc/mail

  #Sendmail 參數(shù)文件所在的目錄

  MAILDIR=/var/mail

  #存放郵箱文件的目錄

  ACCESS=access.db

  #用于臨時存放超過門限值的郵箱名

  SUBACCESS=access.sub

  #用于存放額外的收、轉(zhuǎn)發(fā)限制規(guī)則

 

  1.  if [ -lt 1 ]; then  
  2.  
  3.   error "Must set the MAX mailbox size with the command!"  
  4.  
  5.   fi  
  6.  
  7.   if [ -le 0 ] ; then  
  8.  
  9.   error " Mailbox Size < 0, Failed"  
  10.  
  11.   fi  
  12.  
  13.   ((MAXSIZE=*1024*1024))  
  14.  
  15.   if [ -f / ]; then  
  16.  
  17.   /cat / > / ' '  
  18.  
  19.   error "piping /sintos/,  
  20.  
  21.   Failed"  
  22.  
  23.   else  
  24.  
  25.   > /' 'error "clearing /, Failed"  
  26.  
  27.   fi  
  28.  
  29.   cd ' 'error "entering Failed"  
  30.  
  31.   for box in '/find .  
  32.  
  33.   ! -user root -size +""c -type f -print'; do  
  34.  
  35.   case in  
  36.  
  37.   .|..|./.*.pop)  
  38.  
  39.   ;;  
  40.  
  41.   *)  
  42.  
  43.   mailuser=  
  44.  
  45.   echo "To:@  
  46.  
  47.   ERROR:550 's Mailbox is full " >> /  
  48.  
  49.   ;;  
  50.  
  51.   esac  
  52.  
  53.   done  
  54.  
  55.   cd || error " entering Failed"  
  56.  
  57.   /usr/sbin/makemap dbm access  
  58.  
  59.   < ./ || error "makemaping access Failed"  
  60.  
  61.   exit 0'  
  62.  

  通過以上一系列的命令和方法,就可以設(shè)定sendmail 郵箱的大小

【編輯推薦】

  1.  Sendmail郵件系統(tǒng)的安全解決全方案
  2. Sendmail郵件系統(tǒng)的安全解決全方案
  3. Coremail郵件系統(tǒng)入選廣東Linux產(chǎn)品推薦目錄
  4. Sendmail 配置下載及安裝
  5. 解決Sendmail 配置的兩種方案
  6. Sendmail 安裝升級實現(xiàn)方式
  7. 在php sendmail Windows下配置的具體實現(xiàn)
  8. Linux系統(tǒng)sendmail配置安裝
責任編輯:zhaolei 來源: 網(wǎng)絡轉(zhuǎn)載
相關(guān)推薦

2011-03-04 11:13:11

2011-01-21 13:21:21

sendmail安全

2011-01-21 10:10:44

sendmail

2011-01-21 10:38:52

sendmail

2011-02-25 12:29:25

Proftpd

2011-01-21 11:21:38

sendmail

2011-02-21 16:21:49

Sendmail

2011-01-21 09:17:39

sendmail目錄

2010-06-03 13:44:35

Sendmail配置

2011-01-21 10:40:52

Sendmail

2011-01-18 15:00:57

2011-01-21 09:00:21

sendmail

2011-01-21 09:32:57

LinuxSendmail

2011-01-21 12:12:54

sendmail

2011-01-21 09:49:18

sendmail目錄

2011-01-21 10:39:48

sendmail

2011-01-19 10:11:22

sendmail安裝方法

2011-01-21 15:40:56

Sendmail

2011-01-21 10:59:01

sendmail群發(fā)

2010-06-03 13:21:46

Sendmail 配置
點贊
收藏

51CTO技術(shù)棧公眾號