1Mail::Transport::IMAP4(U3s)er Contributed Perl DocumentatMiaoinl::Transport::IMAP4(3)
2
3
4

NAME

6       Mail::Transport::IMAP4 - proxy to Mail::IMAPClient
7

INHERITANCE

9        Mail::Transport::IMAP4
10          is a Mail::Transport::Receive
11          is a Mail::Transport
12          is a Mail::Reporter
13

SYNOPSIS

15        my $imap = Mail::Transport::IMAP4->new(...);
16        my $message = $imap->receive($id);
17        $imap->send($message);
18

DESCRIPTION

20       The IMAP4 protocol is quite complicated: it is feature rich and allows
21       verious asynchronous actions.  The main document describing IMAP is
22       rfc3501 (which obsoleted the original specification of protocol 4r1 in
23       rfc2060 in March 2003).
24
25       This package, as part of MailBox, does not implement the actual
26       protocol itself but uses Mail::IMAPClient to do the work. The task for
27       this package is to hide as many differences between that module's
28       interface and the common MailBox folder types.  Multiple
29       Mail::Box::IMAP4 folders can share one Mail::Transport::IMAP4
30       connection.
31
32       The Mail::IMAPClient module is the best IMAP4 implementation for Perl5,
33       but is not maintained.  There are many known problems with the module,
34       and solving those is outside the scope of MailBox.  See
35       http://rt.cpan.org/Public/Dist/Display.html?Name=Mail-IMAPClient for
36       all the reported bugs.
37

METHODS

39   Constructors
40       Mail::Transport::IMAP4->new(OPTIONS)
41           Create the IMAP connection to the server.  IMAP servers can handle
42           multiple folders for a single user, which means that connections
43           may get shared.  This is sharing is hidden for the user.
44
45           When an "imap_client" is specified, then the options "hostname",
46           "port", "username", and "password" are extracted from it.
47
48            -Option      --Defined in     --Default
49             authenticate                   'AUTO'
50             domain                         <server_name>
51             executable    Mail::Transport  undef
52             hostname      Mail::Transport  'localhost'
53             imap_client                    Mail::IMAPClient
54             interval      Mail::Transport  30
55             log           Mail::Reporter   'WARNINGS'
56             password      Mail::Transport  undef
57             port          Mail::Transport  143
58             proxy         Mail::Transport  undef
59             retry         Mail::Transport  <false>
60             timeout       Mail::Transport  120
61             trace         Mail::Reporter   'WARNINGS'
62             username      Mail::Transport  undef
63             via           Mail::Transport  'imap'
64
65           authenticate => TYPE|ARRAY-OF-TYPES
66             Authenthication method to login(), which will be passed to
67             Mail::IMAPClient method authenticate().  See the latter method
68             for the available types.
69
70           domain => WINDOWS_DOMAIN
71             Used for NTLM authentication.
72
73           executable => FILENAME
74           hostname => HOSTNAME|ARRAY-OF-HOSTNAMES
75           imap_client => OBJECT|CLASS
76             When an OBJECT is supplied, that client will be used for the
77             implementation of the IMAP4 protocol. Information about server
78             and such are extracted from the OBJECT to have the accessors to
79             produce correct results. The OBJECT shall be a Mail::IMAPClient.
80
81             When a CLASS is given, an object of that type is created for you.
82             The created object can be retreived via imapClient(), and than
83             configured as defined by Mail::IMAPClient.
84
85           interval => SECONDS
86           log => LEVEL
87           password => STRING
88           port => INTEGER
89           proxy => PATH
90           retry => NUMBER|undef
91           timeout => SECONDS
92           trace => LEVEL
93           username => STRING
94           via => CLASS|NAME
95
96   Receiving mail
97       $obj->receive([UNIQUE-MESSAGE-ID])
98           See "Receiving mail" in Mail::Transport::Receive
99
100   Server connection
101       $obj->findBinary(NAME [, DIRECTORIES])
102           See "Server connection" in Mail::Transport
103
104       $obj->remoteHost
105           See "Server connection" in Mail::Transport
106
107       $obj->retry
108           See "Server connection" in Mail::Transport
109
110   Attributes
111       $obj->authentication(['AUTO'|TYPE|LIST-OF-TYPES])
112           Returned is a list of pairs (ref arrays) each describing one
113           possible way to contact the server. Each pair contains a mechanism
114           name and a challenge callback (which may be "undef").
115
116           The settings are used by login() to get server access.  The initial
117           value origins from new(authenticate), but may be changed later.
118
119           Available basic TYPES are "CRAM-MD5", "NTLM", and "PLAIN".  With
120           "AUTO", all available types will be tried.  When the Authen::NTLM
121           is not installed, the "NTLM" option will silently be skipped.  Be
122           warned that, because of "PLAIN", erroneous username/password
123           combinations will be passed readible as last attempt!
124
125           The "NTLM" authentication requires Authen::NTLM to be installed.
126           Other methods may be added later.  Besides, you may also specify a
127           CODE reference which implements some authentication.
128
129           An ARRAY as TYPE can be used to specify both mechanism as callback.
130           When no array is used, callback of the pair is set to "undef".  See
131           "authenticate" in Mail::IMAPClient for the gory details.
132
133           example:
134
135            $transporter->authentication('CRAM-MD5', [MY_AUTH => \&c], 'PLAIN');
136
137            foreach my $pair ($transporter->authentication)
138            {   my ($mechanism, $challange) = @$pair;
139                ...
140            }
141
142       $obj->domain([DOMAIN])
143           Used in NTLM authentication to define the Windows domain which is
144           accessed.  Initially set by new(domain) and defaults to the
145           server's name.
146
147   Exchanging Information
148   Protocol [internals]
149       The follow methods handle protocol internals, and should not be used by
150       a normal user of this class.
151
152       $obj->appendMessage(MESSAGE, FOLDERNAME)
153           Write the message to the server.
154
155       $obj->createFolder(NAME)
156           Add a folder.
157
158       $obj->createImapClient(CLASS)
159           Create an object of CLASS, which extends Mail::IMAPClient.
160
161       $obj->currentFolder([FOLDERNAME])
162           Be sure that the specific FOLDER is the current one selected.  If
163           the folder is already selected, no IMAP traffic will be produced.
164
165           The boolean return value indicates whether the folder is
166           selectable. It will return undef if it does not exist.
167
168       $obj->deleteFolder(NAME)
169           Remove one folder.
170
171       $obj->destroyDeleted(FOLDER)
172           Command the server to delete for real all messages which are
173           flagged to be deleted.
174
175       $obj->fetch(ARRAY-OF-MESSAGES, INFO)
176           Get some INFO about the MESSAGES from the server.  The specified
177           messages shall extend Mail::Box::Net::Message, Returned is a list
178           of hashes, each info about one result.  The contents of the hash
179           differs per INFO, but at least a "message" field will be present,
180           to relate to the message in question.
181
182           The right folder should be selected before this method is called.
183           When the connection was lost, "undef" is returned.  Without any
184           messages, and empty array is returned.  The retrieval is done by
185           Mail::IMAPClient method "fetch()", which is then parsed.
186
187       $obj->flagsToLabels(WHAT|FLAGS)
188           Mail::Transport::IMAP4->flagsToLabels(WHAT|FLAGS)
189
190           In SCALAR context, a hash with labels is returned.  In LIST
191           context, pairs are returned.
192
193           The WHAT parameter can be 'SET', 'CLEAR', or 'REPLACE'.  With the
194           latter, all standard imap flags do not appear in the list will be
195           ignored: their value may either by set or cleared.  See getFlags()
196
197           Unknown flags in LIST are stripped from their backslash and lower-
198           cased.  For instance, '\SomeWeirdFlag' will become `someweirdflag
199           => 1'.
200
201           example: translating IMAP4 flags into MailBox flags
202
203            my @flags  = ('\Seen', '\Flagged');
204            my $labels = Mail::Transport::IMAP4->flags2labels(SET => @flags);
205
206       $obj->folders([FOLDERNAME])
207           Returns a list of folder names which are sub-folders of the
208           specified FOLDERNAME.  Without FOLDERNAME, the top-level
209           foldernames are returned.
210
211       $obj->getFields(UID, NAME, [NAME, ...])
212           Get the records with the specified NAMES from the header.  The
213           header fields are returned as list of Mail::Message::Field::Fast
214           objects.  When the name is "ALL", the whole header is returned.
215
216       $obj->getFlags(FOLDER, ID)
217           Returns the values of all flags which are related to the message
218           with the specified ID.  These flags are translated into the names
219           which are standard for the MailBox suite.
220
221           A HASH is returned.  Names which do not appear will also provide a
222           value in the returned: the negative for the value is it was
223           present.
224
225       $obj->getMessageAsString(MESSAGE|UID)
226           Returns the whole text of the specified message: the head and the
227           body.
228
229       $obj->ids
230           Returns a list of UIDs which are defined by the IMAP server.
231
232       $obj->imapClient
233           Returns the object which implements the IMAP4 protocol, an instance
234           of a Mail::IMAPClient, which is logged-in and ready to use.
235
236           If the contact to the server was still present or could be
237           established, an Mail::IMAPClient object is returned.  Else, "undef"
238           is returned and no further actions should be tried on the object.
239
240       $obj->labelsToFlags(HASH|PAIRS)
241           Mail::Transport::IMAP4->labelsToFlags(HASH|PAIRS)
242
243           Convert MailBox labels into IMAP flags.  Returned is a string.
244           Unsupported labels are ignored.
245
246       $obj->listFlags
247           Returns all predefined flags as list.
248
249       $obj->login
250           Establish a new connection to the IMAP4 server, using username and
251           password.
252
253       $obj->setFlags(ID, LABEL, VALUE, [LABEL, VALUE], ...)
254           Change the flags on the message which are represented by the label.
255           The value which can be related to the label will be lost, because
256           IMAP only defines a boolean value, where MailBox labels can contain
257           strings.
258
259           Returned is a list of LABEL=>VALUE pairs which could not be send to
260           the IMAP server.  These values may be cached in a different way.
261
262   Error handling
263       $obj->AUTOLOAD
264           See "Error handling" in Mail::Reporter
265
266       $obj->addReport(OBJECT)
267           See "Error handling" in Mail::Reporter
268
269       $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])
270           Mail::Transport::IMAP4->defaultTrace([LEVEL]|[LOGLEVEL,
271           TRACELEVEL]|[LEVEL, CALLBACK])
272
273           See "Error handling" in Mail::Reporter
274
275       $obj->errors
276           See "Error handling" in Mail::Reporter
277
278       $obj->log([LEVEL [,STRINGS]])
279           Mail::Transport::IMAP4->log([LEVEL [,STRINGS]])
280
281           See "Error handling" in Mail::Reporter
282
283       $obj->logPriority(LEVEL)
284           Mail::Transport::IMAP4->logPriority(LEVEL)
285
286           See "Error handling" in Mail::Reporter
287
288       $obj->logSettings
289           See "Error handling" in Mail::Reporter
290
291       $obj->notImplemented
292           See "Error handling" in Mail::Reporter
293
294       $obj->report([LEVEL])
295           See "Error handling" in Mail::Reporter
296
297       $obj->reportAll([LEVEL])
298           See "Error handling" in Mail::Reporter
299
300       $obj->trace([LEVEL])
301           See "Error handling" in Mail::Reporter
302
303       $obj->warnings
304           See "Error handling" in Mail::Reporter
305
306   Cleanup
307       $obj->DESTROY
308           The connection is cleanly terminated when the program is
309           terminated.
310
311       $obj->inGlobalDestruction
312           See "Cleanup" in Mail::Reporter
313
314       $obj->url
315           Represent this imap4 connection as URL.
316

DIAGNOSTICS

318       Error: Cannot connect to $host:$port for IMAP4: $!
319       Error: IMAP cannot connect to $host: $@
320       Notice: IMAP4 authenication $mechanism to $host:$port successful
321       Error: IMAP4 requires a username and password
322       Error: IMAP4 username $username requires a password
323       Error: Package $package does not implement $method.
324           Fatal error: the specific package (or one of its superclasses) does
325           not implement this method where it should. This message means that
326           some other related classes do implement this method however the
327           class at hand does not.  Probably you should investigate this and
328           probably inform the author of the package.
329

SEE ALSO

331       This module is part of Mail-Box distribution version 2.097, built on
332       January 26, 2011. Website: http://perl.overmeer.net/mailbox/
333

LICENSE

335       Copyrights 2001-2011 by Mark Overmeer. For other contributors see
336       ChangeLog.
337
338       This program is free software; you can redistribute it and/or modify it
339       under the same terms as Perl itself.  See
340       http://www.perl.com/perl/misc/Artistic.html
341
342
343
344perl v5.12.3                      2011-01-26         Mail::Transport::IMAP4(3)
Impressum