Net::IMAP::Client::MsgSummary(3pm) | User Contributed Perl Documentation | Net::IMAP::Client::MsgSummary(3pm) |
Net::IMAP::Client::MsgSummary - parse message (+ subparts) summary info
This object is created internally in Net::IMAP::Client->get_summaries. You shouldn't need to instantiate it directly. You can skip the SYNOPSIS, these notes are intended for developers.
my $imap = Net::IMAP::Client->new( ... ) $imap->select('INBOX'); # retrieve FETCH lines my ($ok, $lines) = $imap->_tell_imap(FETCH => "$msg_id FULL"); die 'FETCH failed: ' . $imap->last_error unless $ok; # build parsed tokens my @tokens = map { Net::IMAP::Client::_parse_tokens($_) } @$lines; # they look like this: [ '*', 'MSGID', 'FETCH', [ 'FLAGS', [ '\\Seen', '\\Answered' ], 'INTERNALDATE', '13-Aug-2008 14:43:50 +0300', 'RFC822.SIZE', '867', 'ENVELOPE', [ ... ] ... ]
Basically it's the IMAP response parsed into a Perl structure (array of tokens). FIXME: this stuff should be documented in Net::IMAP::Client.
# make summaries my @summaries = map { my $tokens = $_->[3]; my %hash = @$tokens; Net::IMAP::Client::MsgSummary->new(\%hash); } @tokens; my $summary = shift @summaries; print $summary->subject; print $summary->from->[0];
This object can represent a message or a message part. For example, for a message containing attachments you will be able to call parts() in order to fetch parsed Net::IMAP::Client::MsgSummary objects for each part. Each part in turn may contain other subparts! For example, if a part is of type "message/rfc822" then its "parts" method will return it's subparts, if any.
There's a distinction between a message and a message part, although we use the same object to represent both. A message will have additional information, fetched from its ENVELOPE (i.e. "subject", "from", "to", "date", etc.). For a part only, this information will be missing.
If all this sounds confusing, you might want to use Data::Dumper to inspect the structure of a complex message. See also the documentation of Net::IMAP::Client's get_summaries method for an example.
It contains only accessors that return data as retrieved by the FETCH command. Parts that may be MIME-word encoded are automatically undecoded.
Parses/creates a new object from the given FETCH data.
{ inline => { filename => 'foobar.png' } }
Here's a possible message structure:
- Container (multipart/mixed) has no path ID; it's the toplevel message. It contains the following subparts: 1 multipart/related 1.1 text/html 1.2 image/png (embedded in HTML) 2 message/rfc822 (decoded type is actually multipart/related) 2.1 text/html 2.2 image/png (also embedded)
"get_subpart" called on the container will return the respective Net::IMAP::Client::MsgSummary part, i.e. get_subpart('2.1') will return the text/html part of the attached message.
Fix "has_attachments"
Net::IMAP::Client, Net::IMAP::Client::MsgAddress
Mihai Bazon, <mihai.bazon@gmail.com>
http://www.dynarchlib.com/
http://www.bazon.net/mishoo/
Copyright (c) Mihai Bazon 2008. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
2021-01-04 | perl v5.32.0 |