首页 > 技术文章 > Extmail 邮箱服务器 - 批量添加邮箱用户

sharesdk 2018-06-21 15:07 原文

Extmail 邮箱服务器 - 批量添加邮箱用户

需要修改  userctl.pl  文件

修改 userctl.pl 文件

cd /var/www/extsuite/extman/tools

编辑 userctl.pl   修改 sub adduer 模块 和 sub badd 模块;

 1、修改 sub adduer 模块;

注销 my $name 行;重新添加

sub adduser { ... my $email
= $_[0]; my $password = $_[1]; # 添加 my $name = my $name = $_[2]; my ($user,$domain) = split(/@/,$email); ... my $question = defined $opt{question} ? $opt{question} : ""; my $answer = defined $opt{answer} ? $opt{answer} : ""; # 注释 my $name = # my $name = defined $opt{name} ? $opt{name} : $user; my $mailhost = defined $opt{mailhost} ? $opt{mailhost} : ""; }

2、修改 sub badd 模块;

sub badd {
    if(!$opt{file}){
        push @exp, { prompt => "Please input a text file!" , status => 0};
        output ;
    }
    if( -e $opt{file} ){
        my @info;
        my $rv;
        open(BAF,"< $opt{file}")
            or die "Can't open $opt{file} !\n";
        while(<BAF>){
            chomp;
            @info = split(/ /, untaint($_));
       # 添加 $info[2] ; $rv
= adduser $info[0],$info[1],$info[2]; } close BAF; }else{ push @exp, { prompt => "File no exist!" , status => 0}; } output ; }

3、创建 批量邮箱账户模板文件;注意  txt 编码格式需要是 UTF-8 格式;

用户信息文件格式(Email地址、密码、邮箱配额、netdisk配额MB、名字)
# cat adduser.txt

user1@testextmail.com passwd 100 5 user1
user2@testextmail.com passwd 100 5 user2
user3@testextmail.com passwd 100 5 user3
user4@testextmail.com passwd 100 5 user4
user5@testextmail.com passwd 100 5 user5
user6@testextmail.com passwd 100 5 user6
user7@testextmail.com passwd 100 5 user7
user8@testextmail.com passwd 100 5 user8
user9@testextmail.com passwd 100 5 user9

4、执行 perl 批量添加账户:

/var/www/extsuite/extman/tools 当前目录下 

执行:

# perl ./userctl.pl --mod=badd --file=adduser.txt --setuid=1000 --setgid=1000

然后可以到 数据量的 mailbox 表进行查询;

 

推荐阅读