1IMAP(3) User Contributed Perl Documentation IMAP(3)
2
3
4
6 Cyrus::IMAP - Interface to Cyrus imclient library
7
9 use Cyrus::IMAP;
10
11 my $client = Cyrus::IMAP->new('mailhost'[, $flags]);
12 $flags = Cyrus::IMAP::CONN_NONSYNCLITERAL;
13
14 ($server, $mailbox) = Cyrus::IMAP->fromURL($url);
15 $url = Cyrus::IMAP->toURL($server, $mailbox);
16
17 $client->setflags($flags);
18 $client->clearflags(Cyrus::IMAP::CONN_INITIALRESPONSE);
19 $flags = $client->flags;
20 $server = $client->servername;
21 $client->authenticate;
22 $flags = Cyrus::IMAP::CALLBACK_NUMBERED || Cyrus::IMAP::CALLBACK_NOLITERAL;
23 $client->addcallback({-trigger => $str, -flags => $flags,
24 -callback => \&cb, -rock => \$var}, ...);
25 $client->send(\&callback, \&cbdata, $format, ...);
26 $client->processoneevent;
27 ($result, $text) = $client->send(undef, undef, $format, ...);
28 ($fd, $writepending) = $client->getselectinfo;
29
31 The Cyrus::IMAP module provides an interface to the Cyrus imclient
32 library. These are primarily useful for implementing cyradm operations
33 within a Perl script; there are easier ways to implement general client
34 operations, although they may be more limited in terms of
35 authentication options when talking to a Cyrus imapd.
36
37 In the normal case, one will attach to a Cyrus server and authenticate
38 using the best available method:
39
40 my $client = Cyrus::IMAP::new('imap');
41 $client->authenticate;
42 if (!$client->send('', '', 'CREATE %s', 'user.' . $username)) {
43 warn "createmailbox user.$username: $@";
44 }
45
46 In simple mode as used above, "send()" is invoked with "undef", 0, or
47 '' for the callback and rock (callback data) arguments; it returns a
48 list of "($result, $text)" from the command. If invoked in scalar
49 context, it returns $result and places $text in $@. In this mode,
50 there is no need to use "processoneevent()". If more control is
51 desired, use the callback and rock arguments and invoke
52 "processoneevent()" regularly to receive results from the IMAP server.
53 If still more control is needed, the "getselectinfo()" method returns a
54 list containing a file descriptor (not Perl filehandle) which can be
55 passed to select(); if the second element of the list is true, you
56 should include it in the write mask as well as the read mask because
57 the imclient library needs to perform queued output.
58
59 For more information, consult the Cyrus documentation.
60
62 "send()" behaves as if the "Cyrus::IMAP::CONN_NONSYNCLITERAL" flag is
63 always set. This is because it is a wrapper for the C version, which
64 cannot be made directly available from Perl, and synchronous literals
65 require interaction with the IMAP server while parsing the format
66 string. This is planned to be fixed in the future.
67
68 The 'LOGIN' mechanism can be used to authenticate with a plaintext
69 username and password. This is intended as a workaround for a bug in
70 early SASL implementations; use of Cyrus::IMAP with non-Cyrus servers
71 is not recommended, primarily because there are easier ways to
72 implement IMAP client functionality in Perl. (However, if you need
73 SASL support, "Cyrus::IMAP" is currently the only way to get it.)
74
75 The file descriptor returned by "getselectinfo()" should not be used
76 for anything other than "select()". In particular, I/O on the file
77 descriptor will almost certainly cause more problems than whatever
78 problem you think you are trying to solve.
79
80 The toURL and fromURL routines are to ease conversion between URLs and
81 IMAP mailbox and server combinations, and are a simple frontend for the
82 libcyrus functions of the same name.
83
84 The imparse library routines are not implemented, because they are
85 little more than a (failed) attempt to make parsing as simple in C as
86 it is in Perl.
87
88 This module exists primarily so we can integrate Cyrus administration
89 into our Perl-based account management system, and secondarily so that
90 we can rewrite cyradm in a sensible language instead of Tcl. Usability
91 for other purposes is not guaranteed.
92
94 Brandon S. Allbery <allbery@ece.cmu.edu>, Rob Siemborski
95 <rjs3+@andrew.cmu.edu>
96
98 Cyrus::IMAP::Admin perl(1), cyradm(1), imclient(3), imapd(8).
99
100
101
102perl v5.32.0 2020-08-27 IMAP(3)