Mail::...:Fetch(3pm)

πŸ’– NAME πŸ’–

Mail::Server::IMAP4::Fetch β€” bestie, this is the message-info glow-up that makes IMAP go zoom ✨

(it lives in the Mail::...:Fetch(3pm) corner of the User Contributed Perl Documentation, and it is serving)


🌸 SYNOPSIS 🌸

my $imap = Mail::Server::IMAP4::Fetch->new($msg);
print $imap->fetchBody(1);   # for FETCH BODYSTRUCTURE
print $imap->fetchBody;      # for FETCH BODY
print $imap->fetchEnvelope;  # for FETCH ENVELOPE
print $imap->fetchSize;

okay so first things first, that's the whole vibe in four lines 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So what you're doing here is creating a whole new object hierarchy, and its entire job is holding onto the info that captures the most important details about a message. You use it to speed up IMAP-server implementations, like Mail::Box::Netzwert. Slay.

The object in question is a simplified representation of a Mail::Box::Message object. Important: it does not maintain headers and it does not refer to the folder. It only works with messages stored in a file. Which means β€” and this is the iconic part β€” you can freeze this object with Storable if you want to. πŸ’…


πŸŽ€ METHODS πŸŽ€

✨ Constructors ✨

$class->new( <$message|$part>, %options )

Here's the options tea, in a lil table-vibe:

-Option      --Default
 md5checksums  0
  • md5checksums => BOOLEAN β€” default is 0, no cap

🌈 Attributes 🌈

  • $obj->bodyLocation() β€” the body's location, girl. πŸ“
  • $obj->headLocation() β€” and the head's location too
  • $obj->partLocation() β€” plus the part's location, we love a full set

πŸ‘‘ IMAP Commands πŸ‘‘

$obj->fetchBody($extended)

Returns one string, representing the message's structure exactly how the IMAP protocol defines it. The boolean argument is you telling it whether you want the $extended info β€” the kind that the imap command 'FETCH BODYSTRUCTURE' defines β€” or the limited info of 'FETCH BODY'. Choose your fighter ✨

$obj->fetchEnvelope()

Returns a string representation of some header information. cute, brief, useful.

$obj->fetchSize()

Returns the size of the message body. that's it, that's the whole method πŸ’–

$obj->part( [$partnr] )

The partnummer is a list of dot-separated positive integers, numbering (nested) parts in multi-part message bodies. By default, the info of the main message is returned. 🧚

Β» example:

my $partinfo = $msg->info->part('1.2.1');
print $msg->info->part('3.3')->fetchBody;

$obj->printStructure( [<$fh|undef>, [$number]] )

Prints the structure of the fetch data to the specified $fh, or to the selected filehandle. And when you explicitly pass "undef" as the handle, then the output gets returned as a string instead. Heads up though: only a limited set of the information is displayed. πŸ™ˆ

Β» example:

my $imap = ...;
$imap->printStructure(\*OUTPUT);
$imap->printStructure;
my $struct = $imap->printStructure(undef);

πŸ’€ Internals πŸ’€

(this section is giving absolutely nothing, and that's on purpose, bestie β€” there's nothing listed under it)


⭐ DETAILS ⭐

See:

  • RFC2060: "Internet Message Access Protocol IMAP4v1" section 7.4.2
  • RFC2045: "MIME Part One: Format of Internet Message Bodies".

πŸ”₯ SEE ALSO πŸ”₯

This module is part of Mail-Box-IMAP4 version 4.01, built on December 13, 2025. Website: http://perl.overmeer.net/CPAN/


πŸ’œ LICENSE πŸ’œ

For contributors see file ChangeLog.

This software is copyright (c) 2001-2025 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie 🫢 this was perl v5.40.1, dated 2026-01-21, and it's Mail::...:Fetch(3pm) β€” go forth and let your IMAP servers be fast, mwah πŸ’‹

πŸ“¦ where this page comes from