1Mail::Server::IMAP4::LiUsste(r3)Contributed Perl DocumenMtaaitli:o:nServer::IMAP4::List(3)
2
3
4
6 Mail::Server::IMAP4::List - folder related IMAP4 answers
7
9 my $imap = Mail::Server::IMAP4::List->new
10 ( folders => $folders # Mail::Box::Identity
11 , inbox => $inbox # Mail::Box
12 , delimiter => '#'
13 );
14
15 my $imap = Mail::Server::IMAP4::List->new(user => $user);
16 print $imap->list(...); # for LIST command
17
19 Constructors
20 Mail::Server::IMAP4::List->new(USER)
21 Create a (temporary) object to handle the LIST requests for a
22 certain user, based upon a set of folders. The data is kept by
23 Mail::Box::Identity and Mail::Box::Collection objects, which mean
24 that the folders will not be opened to answer these questions.
25
26 -Option --Default
27 delimeter '/'
28 folders <from user>
29 inbox <from user>
30 user <undef>
31
32 delimeter => STRING|CODE
33 Either the constant delimiter, or a code reference which will get
34 passed a folder name and should return the delimiter string used
35 in that name. If that folder name is empty, the default
36 delimiter must be reported. See delimiter() for an example.
37
38 folders => OBJECT
39 You need to specify either a set of folders explicitly or via the
40 user. Some Mail::Box::Identity OBJECT is needed.
41
42 inbox => BOOLEAN
43 For now, only used to see whether there is an inbox, so a truth
44 value will do. This may change in the future. By default, the
45 flag is set if "$user-"inbox> is defined.
46
47 user => OBJECT
48 A Mail::Box::Manage::User OBJECT, representing the user who's
49 folders must get reported.
50
51 Attributes
52 $obj->delimiter([FOLDERNAME])
53 Returns the delimiter string. The foldername is only required when
54 a CODE reference was specified at initiation.
55
56 example: setting-up an IMAP4 delimeter
57
58 sub delim($)
59 { my $path = shift;
60 my ($delim, $root)
61 = $path =~ m/^(#news\.)/ ? ('.', $1)
62 = $path =~ m!^/! ? ('/', '/')
63 : ('/', '');
64
65 wantarray ? ($delim, $root) : $delim;
66 }
67
68 my $list = Mail::Server::IMAP4::List->new(delimiter => \&delim, ...);
69 print $list->delimiter('abc/xyz'); # returns a / (slash) and ''
70 print $list->delimiter('#news.feed'); # returns a . (dot) and $news.
71 print $list->delimiter(''); # returns default delimiter
72
73 $obj->folders
74 Returns the Mail::Box::Identity of the toplevel folder.
75
76 $obj->inbox
77 Returns the Mail::Box or filename of the INBOX.
78
79 $obj->user
80 Returns the Mail::Box::Manage::User object, if defined.
81
82 IMAP Commands
83 $obj->list(BASE, PATTERN)
84 IMAP's LIST command. The request must be partially decoded, the
85 answer will need to be encoded.
86
87 example: using IMAP list
88
89 my $imap = Mail::Server::IMAP4::List->new(delimiter => \&delim, ...);
90 local $" = ';';
91
92 my @lines = $imap->list('', ''); # returns the default delimiter
93 print ">@{$lines[0]}<"; # >(\Noselect);/;<
94
95 my @lines = $imap->list('#news',''); # specific delimiter
96 print ">@{$lines[0]}<"; # >(\Noselect);.;<
97
98 my @lines = $imap->list('top/x/', '%');
99 print ">@$_<," foreach @lines; # >();/;/tmp/x/y<,>(\Marked);/;/tmp/x/z<
100
102 See
103
104 RFC2060: "Internet Message Access Protocol IMAP4v1"
105 sections 6.3.8 (LIST question) and 7.2.2 (LIST answer)
106
108 This module is part of Mail-Box distribution version 2.097, built on
109 January 26, 2011. Website: http://perl.overmeer.net/mailbox/
110
112 Copyrights 2001-2011 by Mark Overmeer. For other contributors see
113 ChangeLog.
114
115 This program is free software; you can redistribute it and/or modify it
116 under the same terms as Perl itself. See
117 http://www.perl.com/perl/misc/Artistic.html
118
119
120
121perl v5.12.3 2011-01-26 Mail::Server::IMAP4::List(3)