因为工作的需要经常需要批量添加用户。因此采用qmailadmin就不太合适了,参考了gadfly老大的http://www.chinaunix.net/forum/viewtopic.php?t=894这篇文章,自己写了个脚本,不敢独享。
欢迎转载,转载时注明出处
作者:seacaptain
时间:2003年11月4日
#!/bin/sh
EMAIL=$1
PASS=$2
DOMAIN=`echo $EMAIL | cut -d"@" -f2`
USER=`echo $EMAIL | cut -d"@" -f1`
HOMEDIR="/home/vpopmail/domains/$DOMAIN/$USER"
MAILDIR="/home/vpopmail/domains/$DOMAIN/$USER/Maildir"
DOMAINDIR="/home/vpopmail/domains/$DOMAIN/"
#echo $HOMEDIR $MAILDIR
#echo $EMAIL $USER $DOMAIN
PATH=$PATH:/home/vpopmail/bin
export PATH
vadduser $EMAIL $PASS
umask 0177
#.qmail-user file
echo "|maildrop $HOMEDIR/.mailfilter" > $DOMAINDIR/.qmail-$USER
#
#.mailfilter file
#
echo "include $HOMEDIR/.userfilter" >> $HOMEDIR/.mailfilter
echo "to "$MAILDIR/."" >> $HOMEDIR/.mailfilter
#
#maildirfilterconfig file
#
echo "MAILDIRFILTER=../.userfilter" >> $MAILDIR/maildirfilterconfig
echo "MAILDIR=$MAILDIR" >> $MAILDIR/maildirfilterconfig
#
#.userfilter file
#
echo "#MFMAILDROP=2" >> $HOMEDIR/.userfilter
echo "#" >> $HOMEDIR/.userfilter
echo "#This is an automatically generated filter." >> $HOMEDIR/.userfilter
echo "FROM='$EMAIL'" >> $HOMEDIR/.userfilter
echo "import SENDER" >> $HOMEDIR/.userfilter
echo "if ( \$SENDER ne "")" >> $HOMEDIR/.userfilter
echo "{ FROM=$SENDER }">>$HOMEDIR/.userfilter
echo "to "$MAILDIR/."" >> $HOMEDIR/.userfilter
chown vpopmail.vchkpw $HOMEDIR/.mailfilter
chown vpopmail.vchkpw $HOMEDIR/.userfilter
chown vpopmail.vchkpw $MAILDIR/maildirfilterconfig
添加用户./quser.sh user@abc.com pass就可以了。
设置过滤规则可以手工修改$homedir/.mailfilter文件。在里面加入规则即可
也可以通过sqwebmail设置过滤规则。
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073