Cyrus::IMAP − Interface to Cyrus imclient library


  use Cyrus::IMAP;
  my $client = Cyrus::IMAP−>new('mailhost'[, $flags]);
  ($server, $mailbox) = Cyrus::IMAP−>fromURL($url);
  $url = Cyrus::IMAP−>toURL($server, $mailbox);
  $flags = $client−>flags;
  $server = $client−>servername;
  $client−>addcallback({−trigger => $str, −flags => $flags,
                        −callback => \&cb, −rock => \$var}, ...);
  $client−>send(\&callback, \&cbdata, $format, ...);
  ($result, $text) = $client−>send(undef, undef, $format, ...);
  ($fd, $writepending) = $client−>getselectinfo;


The Cyrus::IMAP module provides an interface to the Cyrus imclient library. These are primarily useful for implementing cyradm operations within a Perl script; there are easier ways to implement general client operations, although they may be more limited in terms of authentication options when talking to a Cyrus imapd.

In the normal case, one will attach to a Cyrus server and authenticate using the best available method:

        my $client = Cyrus::IMAP::new('imap');
        if (!$client−>send('', '', 'CREATE %s', 'user.' . $username)) {
          warn "createmailbox user.$username: $@";

In simple mode as used above, "send()" is invoked with "undef", 0, or '' for the callback and rock (callback data) arguments; it returns a list of "($result, $text)" from the command. If invoked in scalar context, it returns $result and places $text in $@. In this mode, there is no need to use "processoneevent()". If more control is desired, use the callback and rock arguments and invoke "processoneevent()" regularly to receive results from the IMAP server. If still more control is needed, the "getselectinfo()" method returns a list containing a file descriptor (not Perl filehandle) which can be passed to select(); if the second element of the list is true, you should include it in the write mask as well as the read mask because the imclient library needs to perform queued output.

For more information, consult the Cyrus documentation.


"send()" behaves as if the "Cyrus::IMAP::CONN_NONSYNCLITERAL" flag is always set. This is because it is a wrapper for the C version, which cannot be made directly available from Perl, and synchronous literals require interaction with the IMAP server while parsing the format string. This is planned to be fixed in the future.

The 'LOGIN' mechanism can be used to authenticate with a plaintext username and password. This is intended as a workaround for a bug in early SASL implementations; use of Cyrus::IMAP with non-Cyrus servers is not recommended, primarily because there are easier ways to implement IMAP client functionality in Perl. (However, if you need SASL support, "Cyrus::IMAP" is currently the only way to get it.)

The file descriptor returned by "getselectinfo()" should not be used for anything other than "select()". In particular, I/O on the file descriptor will almost certainly cause more problems than whatever problem you think you are trying to solve.

The toURL and fromURL routines are to ease conversion between URLs and IMAP mailbox and server combinations, and are a simple frontend for the libcyrus functions of the same name.

The imparse library routines are not implemented, because they are little more than a (failed) attempt to make parsing as simple in C as it is in Perl.

This module exists primarily so we can integrate Cyrus administration into our Perl-based account management system, and secondarily so that we can rewrite cyradm in a sensible language instead of Tcl. Usability for other purposes is not guaranteed.


Brandon S. Allbery <>, Rob Siemborski <>


Cyrus::IMAP::Admin perl(1), cyradm(1), imclient(3), imapd(8).

More Linux Commands

XtDirectConvert(3) - invoke resource converters (Man Page)
The XtConvert function looks up the type converter registered to convert from_type to to_type, computes any additional arguments needed, and then calls XtDirect

use_window(3ncurses) - curses thread support (Man Page).....
This implementation can be configured to provide rudimentary support for multi-threaded applications. This makes a different set of libraries, e.g., libncursest

vwarnx(3) - formatted error messages - Linux manual page....
The err() and warn() family of functions display a formatted error message on the standard error output. In all cases, the last component of the program name, a

Tcl_SpliceChannel(3) - procedures for creating and manipulat
Tcl uses a two-layered channel architecture. It provides a generic upper layer to enable C and Tcl programs to perform input and output using the same APIs for

scanimage(1) - scan an image (Commands - Linux man page)....
scanimage is a command-line interface to control image acquisition devices such as flatbed scanners or cameras. The device is controlled via command-line option

ddp(7) - Linux AppleTalk protocol implementation (Man Page)
Linux implements the AppleTalk protocols described in Inside AppleTalk. Only the DDP layer and AARP are present in the kernel. They are designed to be used via

plymouthd(8) The plymouth daemon (Admin - Linux man page)...
The plymouthd daemon is usually run out of the initrd. It does the heavy lifting of the plymouth system, logging the session and showing the splash screen. The

auparse_get_time(3) - get event's time - Linux manual page
auparse_get_time will access just the time portion of the timestamp data structure for the current event. RETURN VALUE Returns 0 if an error occurs; otherwise,

meta(3ncurses) - curses input options - Linux manual page...
Normally, the tty driver buffers typed characters until a newline or carriage return is typed. The cbreak routine disables line buffering and erase/kill charact

s3(4) - S3 video driver (Special files - Linux man page)....
s3 is an Xorg driver for S3 based video cards. The driver provides full accelerated support for the following colour depths: 8, 15, 16 and 24. The overlay video

strings(1) - print the strings of printable characters in fi
For each file given, GNU strings prints the printable character sequences that are at least 4 characters long (or the number given with the options below) and a

outsw(2) - port I/O (System calls - Linux man page).........
This family of functions is used to do low-level port input and output. The out* functions do port output, the in* functions do port input; the b-suffix functio

We can't live, work or learn in freedom unless the software we use is free.