I use the following perl script to create users: (Put in valid
userid/passwd for $user and $pass)
#!/usr/bin/perl -w
# adduser.pl
# Usage: adduser.pl newuser
#
use File::Basename;
use Net::IMAP;
$newuser = "user.$ARGV[0]";
$user = "user";
$pass = "password";
# Set this to the hostname of your IMAP server
# $IMAPSERVER = "142.227.51.106";
$IMAPSERVER = "localhost";
#
# Main Code
#
# Login to IMAP server
$imap = new Net::IMAP($IMAPSERVER, Synchronous => 1) || die "no go
$! !";
$response = $imap->login($user, $pass);
print "Login: ", $response->status, "-", $response->status_text, "\n";
# Create the new mailbox
$response = $imap->create($newuser);
print "Create: ", $response->status, "-", $response->status_text, "\n";
# Disconnect from IMAP server
$response = $imap->logout();
print "Logout: ", $response->status, "-", $response->status_text, "\n";
Sandra Regina wrote:
>I have been searching the archive messages for a script to create
>mailbox, but I have found it only in TCL. I have read on man pages
>that cyradm in tcl is not supported any more.
>Does anyone has the following script in Perl ?
>
>Thanks a lot
>
>Sandra
>
>su first
> cyradm -file adduser.tcl
>
> if {$argc != 1} {
> puts "usage: No user list specifiled."
> exit 1
> }
>
> set infile [lindex $argv 0 ]
> set quota 512
>
> eval cyradm connect cyr_conn host
> eval cyr_conn authenticate -pwcommand {{
> set hostname "myhost"
> set adminid "cyrus"
> set adminpw "the password"
> list $adminid $adminpw
> }
> }
>
> if [catch {open $infile} IN] {
> puts stderr "Can not open file $infile: $IN"
> exit 1
> }
>
> while {[gets $IN mailbox] >= 0} {
> exec /usr/sbin/adduser -batch $mailbox email $mailbox $mailbox
> cyr_conn createmailbox user.$mailbox
> cyr_conn setquota user.$mailbox storage $quota
> cyr_conn createmailbox user.$mailbox.sentmail
> }
> close $IN
>
>
>