Mail::Cap(3)
π Mail::Cap(3) β understand mailcap files π
okay so this is Mail::Cap(3), from the User Contributed Perl Documentation section of your manpages, and bestie it is literally the friend who reads your mailcap files so you don't have to π
β¨ SYNOPSIS β¨
my $mc = Mail::Cap->new;
my $desc = $mc->description('image/gif');
print "GIF desc: $desc\n";
my $cmd = $mc->viewCmd('text/plain; charset=iso-8859-1', 'file.txt');
that's the whole vibe honestly π¦ make an object, ask it what a GIF is, ask it how to view a file. iconic.
πΈ DESCRIPTION πΈ
so this module parses mailcap files, exactly as specified in "RFC 1524 --A User Agent Configuration Mechanism For Multimedia Mail Format Information>. no cap, that's the actual spec, it's giving very 1993 but it still slaps.
in the description below, $type refers to the MIME type as specified in the "Content-Type" header of mail or HTTP messages. examples of types are:
image/gif
text/html
text/plain; charset=iso-8859-1
okay and a little side note from the module itself β you could also take a look at the File::MimeInfo distribution, because those are accessing tables which are used by many applications on a system, and therefore have succeeded the mail-cap specifications on modern (UNIX) systems. so like, the mailcap era is lowkey over on modern UNIX, but this still works π«Ά
π METHODS π
π§ Constructors
Mail::Cap->new(%options)β create and initialize a newMail::Capobject β¨ if you give it an argument it will try to parse the specified file. without any arguments it will search for the mailcap file using the standard mailcap path, or theMAILCAPSenvironment variable if it is defined. default girlfriend behaviour: figure it out yourself πββοΈ
-Option --Default
filename undef
take 'FIRST'
filename => FILENAMEβ add the specified file to the list to standard locations. this file is tried first. like, she gets VIP access πtake => 'ALL'|'FIRST'β include all mailcap files you can find. by default, only the first file is parsed, however the RFC tells us to include ALL. but to maintain backwards compatibility, the default only takes the FIRST. so like, the RFC is screaming "ALL" and the default is quietly "FIRST" π we respect the legacy.
example:
$mcap = new Mail::Cap;
$mcap = new Mail::Cap "/mydir/mailcap";
$mcap = new Mail::Cap filename => "/mydir/mailcap";
$mcap = new Mail::Cap take => 'ALL';
$mcap = Mail::Cap->new(take => 'ALL');
(yes, new Mail::Cap without the arrow is in there, it's old-school and it ate π)
π₯ Run commands
these methods invoke a suitable program presenting or manipulating the media object in the specified file. they all return 1 if a command was found, and 0 otherwise. you might test $? for the outcome of the command β very much a "check your receipts" moment π§Ύ
$obj->compose($type, $file)$obj->edit($type, $file)$obj->print($type, $file)$obj->view($type, $file)
β Command creator
these methods return a string that is suitable for feeding to system() in order to invoke a suitable program presenting or manipulating the media object in the specified file. it will return "undef" if no suitable specification exists π (so like, always check for undef before you system() it, bestie, fr fr)
$obj->composeCmd($type, $file)$obj->editCmd($type, $file)$obj->printCmd($type, $file)$obj->viewCmd($type, $file)
π Look-up definitions
methods return the corresponding mailcap field for the type π
$obj->description($type)$obj->field($type, $field)β returns the specified field for the type. returnsundefif no specification exists.$obj->nametemplate($type)$obj->textualnewlines($type)$obj->x11_bitmap($type)
π¦ SEE ALSO π¦
this module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. go look, iykyk π
π AUTHORS π
the MailTools bundle was developed by Graham Barr. later, Mark Overmeer took over maintenance without commitment to further development. (slay for stepping up, but also, no promises π)
Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. for other contributors see ChangeLog.
π LICENSE π
copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2024 Mark Overmeer <perl@overmeer.net>.
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. see http://www.perl.com/perl/misc/Artistic.html. periodt π
and that's the whole page bestie!! π footer tea: this was generated by perl v5.42.0 and dated 2024-12-12, and it's Mail::Cap(3) β go hydrate and go parse some mailcap files π§π
π¦ where this page comes from
- opensuse-leap 16.0: perl-MailTools 2.220.0-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms