Mail::Cache - Caches mail info.
Version 0.1.2
use Mail::Cache; my $mc = Mail::Cache->new(); #init for the module 'ZConf::Mail' for a IMAP account named 'foo@bar' for the box 'INBOX' $mc->init('ZConf::Mail', 'imap', 'foo@bar', 'INBOX'); #populate a cache from a Mail::IMAPTalk object $imap->select('INBOX'); my $sorted=$imap->sort('(subject)', 'UTF8', 'NOT', 'DELETED'); my $int=0; while(defined($sorted->[$int])){ my $headers=$imap->fetch($sorted->[$int], 'rfc822.header'); my $size=$imap->fetch($sorted->[$int], 'rfc822.size'); $mc->setUID($sorted->[$int], $headers->{$sorted->[$int]}{'rfc822.header'}, $size->{$sorted->[$int]}{'rfc822.size'}); if($mc->{error}){ print "Error!\n"; } $int++; }
This sets the account that is currently being worked with.
my $account=$mc->getAccount;
This gets the current mail box being used.
my $box=$mc->getBox;
This gets the name of the current cache.
my $cache=$mc->getCache;
This fetches a parsed hash of the dates.
The returned hash has the UIDs as the keys and the value for each hash entry is the the date from the header.
my %dates=$mc->getDates; if($mc->{error}){ print "Error!\n"; }
This fetches a parsed hash of the subjects.
The returned hash has the UIDs as the keys and the value for each hash entry is the the subject.
my %subjects=$mc->getSizes; if($mc->{error}){ print "Error!\n"; }
This fetches a parsed hash of the froms.
The returned hash has the UIDs as the keys and the value for each hash entry is the the froms.
my %sizes=$mc->getSizes; if($mc->{error}){ print "Error!\n"; }
This fetches a parsed hash of the sizes.
The returned hash has the UIDs as the keys and the value for each hash entry is the the size.
This gets the current type.
my $type=$mc->getType;
A short cut to calling the three different set methods.
$mc->init($cache, $type, $account, $box); if($mc->{error}){ print "Error!\n"; }
This gets a list of UIDs.
my @uids=$mc->listUIDs; if($mc->{error}){ print "Error!\n"; }
This removes a array of specified UIDs. This is used for cleaning it up. See Mail::IMAPTalk::MailCache for a example of how to use this.
$mc->removeUIDs(\@uids);
This sets the account that is currently being worked on. The default is 'default'.
A value of '' or undef will set it back to the default.
This sets the current box in use.
A value of '' or undef will set it back to the default, 'INBOX'.
This sets the name cache.
A value of '' or undef will set it back to the default, 'Mail::Cache'.
#set the cache name to ZConf::Mail $mc->setCache('ZConf::Mail'); if($mc->{error}){ print "Error!\n"; }
This sets what source of what is being cached. The default is 'imap'.
Regardless of what it is set to, it will be converted to lower case.
$mc->setType('imap'); if($mc->{error}){ print "Error!\n"; }
This sets the cache for a message. If it does not already exist, it will be added. If it does exist, it will be overwritten.
$mc->setUID($uid, $headers, $size); if($mc->{error}){ print "Error!\n"; }
A internal functions that blanks any previous error.
The cache exists under "xdg_cache_home.'/Mail::Cache/'". So the default location would be "~/.cache/Mail::Cache/".
Under the cache home directory is the directories representing various caches. If none is specified it is 'Mail::Cache'. This would make the directory, "xdg_cache_home.'/Mail::Cache/Mail::Cache/'".
Under the cache directory is the type directory. The type should also always be lower case. Any upper case characters will be converted to lowercase. The default is 'imap', making the directory "xdg_cache_home.'/Mail::Cache/Mail::Cache/imap/'".
Under the account directory is the type directory. The default is 'default', making the directory "xdg_cache_home.'/Mail::Cache/Mail::Cache/imap/default/'".
Under the box directory is the account directory. The default is 'INBOX', making the directory "xdg_cache_home.'/Mail::Cache/Mail::Cache/imap/default/INBOX/'".
The error codes are stored in '$mc->{error}'. Any time it is true, an error is present. When no error is present, it is undefined.
A description of the error can be found in '$mc->{errorString}'.
Could not create xdg_cache_home.
Could not create xdg_cache_home.'/Mail::Cache/'.
Cache name contains a '/'.
Failed to create xdg_cache_home.'/'.$cache.'/'.
Type contains a '/'.
Account contains a '/'.
Failed to create create xdg_cache_home.'/'.$cache.'/'.$account.'/'.
No UID specified.
UID matches /^\./.
No headers given.
Size is not specified.
UID matches /\|/.
Box name matches /\//.
Failed to create create xdg_cache_home.'/'.$cache.'/'.$account.'/'.$box.'/'.
"xdg_cache_home.'/'.$cache.'/'.$account.'/'.$box.'/'" does not exist.
"xdg_cache_home.'/'.$cache.'/'.$account.'/'.$box.'/.Size'" does not exist.
The passed value for the headers was something other than a reference or a hash.
Zane C. Bowers, <vvelox at vvelox.net>
<vvelox at vvelox.net>
Please report any bugs or feature requests to bug-mail-cache at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mail-Cache. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mail-cache at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Mail::Cache
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mail-Cache
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Mail-Cache
CPAN Ratings
http://cpanratings.perl.org/d/Mail-Cache
Search CPAN
http://search.cpan.org/dist/Mail-Cache/
Copyright 2009 Zane C. Bowers, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Mail::Cache, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mail::Cache
CPAN shell
perl -MCPAN -e shell install Mail::Cache
For more information on module installation, please visit the detailed CPAN module installation guide.