Re: adding users via script

From: Steven M Bloomfield (no email)
Date: Fri Mar 08 2002 - 11:48:50 EST

here's something really simple i threw together, hope it helps.

#!/usr/local/bin/perl -w
# Really simple create mailbox script
# by Steven Bloomfield -
# This script only creates a new mailbox, I use MySQL for authentication
# to execute from command line
# perl /path/to/ username
# to execute within a PHP script
# <?exec ("perl /path/to/ ".$login);?>
# I used $login as a variable passed from a form
# To see this script in action visit
# Thanks to david eitzinger for help with authenticating pam->mysql database

use Cyrus::IMAP::Admin;

# hostname of IMAP server
$server = "localhost";

# user and password for cyradm
$user = "cyrususername";
$pass = "cyruspassword";

# Authenticate
my $cyrus = Cyrus::IMAP::Admin->new($server);
$cyrus->authenticate(-mechanism => 'login', -user => $user, -password =>
die $cyrus->error if $cyrus->error;

$adduser = $ARGV[0];
$quota = "2000";
my $mbox = 'user.' . $adduser;

# Create the account
print STDERR "Creating $mbox on \n" if $debug;
warn $cyrus->error if $cyrus->error;
# Set the quota
if ($quota)
  print STDERR "Setting quota for $mbox to $quota\n" if $debug;
  $cyrus->setquota($mbox, 'STORAGE', $quota);
  warn $cyrus->error if $cyrus->error;

----- Original Message -----
From: "Birger Toedtmann" <>
To: "Jeff Bert" <>
Cc: <>
Sent: Friday, March 08, 2002 4:30 PM
Subject: Re: adding users via script

Jeff Bert schrieb am Fri, Mar 08, 2002 at 08:02:44AM -0800:
> I'm trying to find a script that will allow me to add users via a single
> command line entry.
> I found "" at sourceforge but it seems to choke on every call
> to the Cyrus::IMAP libraries.
> Has anyone done something like this or modified this perl script to work?

I had this tiny one for testing, maybe you find it useful (but is perl as
well and uses Cyrus::IMAP, so if they are broken, you're lost)



Hosted Email Solutions

Invaluement Anti-Spam DNSBLs

Powered By FreeBSD   Powered By FreeBSD