网上搜了下有两种方法:磁盘配额和脚本
第一种方法毕竟需要懂硬盘,个人不想使用,所以没去试。
第二种方法参考网上的试了一下,但是没有效果。估计环境不一样,脚本语言也看不太懂
,也没日志查看错误,不知道问题出在哪了。
脚本如下:
#!/usr/bin/ksh
# search the mailbox larger than MAXSIZE , then set this mailbox full and reject new mails
error() {
echo " $1 "
exit 1
}
BIN=/usr/bin
MAIL=/etc/mail
#Sendmail 参数文件所在的目录
MAILDIR=/var/mail
#存放邮箱文件的目录
ACCESS=access.db
#用于临时存放超过门限值的邮箱名
SUBACCESS=access.sub
#用于存放额外的收、转发限制规则
if [ $# -lt 1 ]; then
error "Must set the MAX mailbox size with the command!"
fi
if [ $1 -le 0 ] ; then
error " Mailbox Size < 0, Failed"
fi
((MAXSIZE=$1*1024*1024))
if [ -f $MAIL/$SUBACCESS ]; then
$BIN/cat $MAIL/$SUBACCESS > $MAIL/$ACCESS
error "piping $MAIL/$SUBACCESS into $MAIL/$ACCESS, Failed"
else
> $MAIL/$ACCESS error "clearing $MAIL/$ACCESS, Failed"
fi
cd $MAILDIR error "entering $MAILDIR Failed"
for box in $BIN/find .
! -user root -size +"$MAXSIZE"c -type f -print; do
case $box in
.|..|./.*.pop)
;;
*)
mailuser=${box#./}
echo "To:$mailuser@
ERROR:550 $mailusers Mailbox is full " >> $MAIL/$ACCESS
;;
esac
done
cd $MAIL || error " entering $MAIL Failed"
/usr/sbin/makemap dbm access
< ./$ACCESS || error "makemaping access Failed"
exit 0
各位大大看看这个脚本有没有什么问题,或者有哪些地方需要根据实际环境进行修改的。
亦或者有没有其他方法限制用户邮箱容量。
万分感谢!
分享至: