NAME
IMAP::Admin - Perl module for basic IMAP server administration
SYNOPSIS
use IMAP::Admin;
$imap = IMAP::Admin->new('Server' => 'name.of.server.com',
'Port' => port# (143 is default),
'Login' => 'login_of_imap_administrator',
'Password' => 'password_of_imap_adminstrator');
$err = $imap->create("user.bob");
if ($err != 0) {
print "$imap->{'Error'}\n";
}
$err = $imap->create("user.bob", "green");
$err = $imap->delete("user.bob");
@quota = $imap->get_quotaroot("user.bob");
@quota = $imap->get_quota("user.bob");
$err = $imap->set_quota("user.bob", 10000);
@acl = $imap->get_acl("user.bob");
$err = $imap->set_acl("user.bob", "admin", "lrswipdca", "joe", "lrs");
$err = $imap->delete_acl("user.bob", "joe", "admin");
@list = $imap->list("user.bob");
@list = $imap->list("user.b*");
$imap->{'Capability'} # this contains the Capabilities reply from the IMAP server
$imap->close; # close open imap connection
DESCRIPTION
IMAP::Admin provides basic IMAP server adminstration. It provides functions for creating and deleting mailboxes and setting various information such as quotas and access rights.
It's interface should, in theory, work with any RFC compliant IMAP server, but I currently have only tested it against Carnegie Mellon University's Cyrus IMAP and Mirapoint's IMAP servers. It does a CAPABILITY check for specific extensions to see if they are supported.
Operationally it opens a socket connection to the IMAP server and logs in with the supplied login and password. You then can call any of the functions to perform their associated operation.
MAILBOX FUNCTIONS
RFC2060 commands. These should work with any RFC2060 compliant IMAP mail servers.
create makes new mailboxes. Cyrus IMAP, for normal mailboxes, has the user. prefix. create returns a 0 on success or a 1 on failure. An error message is placed in the object->{'Error'} variable on failure. create takes an optional second argument that is the partition to create the mailbox in (I don't know if partition is rfc or not, but it is supported by Cyrus IMAP and Mirapoint).
delete destroys mailboxes. delete returns a 0 on success or a 1 on failure. An error message is placed in the object->{'Error'} variable on failure.
list lists mailboxes. list accepts wildcard matching
QUOTA FUNCTIONS
NOT RFC2060 commands. These are supported by Cyrus IMAP and Mirapoint.
get_quotaroot and get_quota retrieve quota information. They return an array on success and undef on failure. In the event of a failure the error is place in the object->{'Error'} variable. The array has three elements for each item in the quota. $quota[0] <- mailbox name $quota[1] <- quota amount used in kbytes $quota[2] <- quota in kbytes
set_quota sets the quota. The number is in kilobytes so 10000 is approximately 10Meg. set_quota returns a 0 on success or a 1 on failure. An error message is placed in the object->{'Error'} variable on failure.
To delete a quota do a set_quota($mailbox, "none");
ACCESS CONTROL FUNCTIONS
NOT RFC2060 commands. These are supported by Cyrus IMAP and Mirapoint.
get_acl retrieves acl information. It returns an array on success and under on failure. In the event of a failure the error is placed in the object->{'Error'} variable. The array contains a pair for each person who has an acl on this mailbox $acl[0] user who has acl information $acl[1] acl information $acl[2] next user ...
set_acl set acl information for a single mailbox. You can specify more the one user's rights on the same set call. It returns a 0 on success or a 1 on failure. An error message is placed in the object->{'Error'} variable on failure.
delete_acl removes acl information on a single mailbox for the given users. You can specify more the one users rights to be removed in the same delete_acl call. It returns a 0 on success or a 1 on failure. An error message is placed int the object->{'Error'} variable on failure.
The access control information is from Cyrus IMAP. read = "lrs" post = "lrsp" append = "lrsip" write = "lrswipcd" all = "lrswipcda"
KNOWN BUGS
Currently all the of the socket traffic is handled via prints and <>. This means that some of the calls could hang if the socket connection is broken. Eventually the will be properly selected and timed.
CVS REVISION
$Id: Admin.pm,v 1.16 2000/03/02 18:09:13 eric Exp $
AUTHOR
Eric Estabrooks, eric@urbanrage.com
SEE ALSO
perl(1).