IMAP-Admin
view release on metacpan or search on metacpan
foreach $ssl_key (keys(%ssl_defaults)) {
if (!defined($self->{$ssl_key})) {
$self->{$ssl_key} = $ssl_defaults{$ssl_key};
}
}
foreach $ssl_key (keys(%{$self})) {
if ($ssl_key =~ /^SSL_/) {
push @ssl_options, $ssl_key, $self->{$ssl_key};
}
}
my $SSL_try = "use IO::Socket::SSL";
eval $SSL_try;
# $IO::Socket::SSL::DEBUG = 1;
if (!eval {
$self->{'Socket'} =
IO::Socket::SSL->new(PeerAddr => $self->{'Server'},
PeerPort => $self->{'Port'},
Proto => 'tcp',
Reuse => 1,
Timeout => 5,
@ssl_options); }) {
$self->_error("initialize", "couldn't establish SSL connection to",
$self->{'Server'}, "[$!]");
delete $self->{'Socket'};
return;
}
use IMAP::Admin;
$imap = IMAP::Admin->new('Server' => 'name.of.server.com',
'Login' => 'login_of_imap_administrator',
'Password' => 'password_of_imap_adminstrator',
'Port' => port# (143 is default),
'Separator' => ".", # default is a period
'CRAM' => 1, # off by default, can be 0,1,2
'SSL' => 1, # off by default
# and any of the SSL_ options from IO::Socket::SSL
);
$err = $imap->create("user.bob");
if ($err != 0) {
print "$imap->{'Error'}\n";
}
if ($err != 0) {
print $imap->error;
}
$err = $imap->create("user.bob", "green");
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...
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.
Separator on the new call is the hiearchical separator used by the imap server. It is defaulted to a period ("/" might be another popular one).
CRAM on the new call will attempt to use CRAM-MD5 as the login type of choice. A value of 0 means off, 1 means on, 2 means on with fallback to login. *Note* this options requires these perl modules: Digest::MD5, Digest::HMAC, MIME::Base64
SSL on the new call will attempt to make an SSL connection to the imap server. It does not fallback to a regular connection if it fails. It is off by default. IO::Socket::SSL requires a ca certificate, a client certificate, and a client private ke...
If you start the name of the server with a / instead of using tcp/ip it'll attempt to use a unix socket.
I generated my ca cert and ca key with openssl:
openssl req -x509 -newkey rsa:1024 -keyout ca-key.pem -out ca-cert.pem
I generated my client key and cert with openssl:
openssl req -new -newkey rsa:1024 -keyout client-key.pem -out req.pem -nodes
openssl x509 -CA ca-cert.pem -CAkey ca-key.pem -req -in req.pem -out client-cert.pem -addtrust clientAuth -days 600
- added new option to the new function 'Separator', set this
to the hiearchical separator your server uses (defaults to period)
this is needed by h_delete
1.3.8 Wed Oct 25 11:50:49 2000
- fixed a 'bug' in list for servers that don't quote mailboxes
that have spaces in folder names
- fixed a bug in test that I introduced in 1.3.7
1.4.0 Thu Oct 26 11:59:56 2000
- added SSL support via IO::Socket::SSL (optional new function).
imap::admin doesn't attempt to load IO::Socket::SSL until you
specify that you want to use ssl (so if you don't have it
installed on your box it shouldn't make a difference)
- rearranged code so croaks do not happen for connection issues,
instead you get an error from initialize code when you try to
do a command. (This is to help all of those people using this
in cgi scripts)
- in supporting ssl I had to switch to sysreads, so now all reads
are handled by _read (still doesn't select, but getting closer)
- currently it doesn't check for ssl capability (rfc2595 compliance),
but maybe in the future
( run in 0.631 second using v1.01-cache-2.11-cpan-0d8aa00de5b )