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 new Mail::Cap object ✨ 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 the MAILCAPS environment 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. returns undef if 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