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