man-pages/man3/Mail::Cap.3pm.html
2021-03-31 01:06:50 +01:00

303 lines
6.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Mail::Cap</TITLE>
</HEAD><BODY>
<H1>Mail::Cap</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-07-25<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Mail::Cap - understand mailcap files
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
my $mc = Mail::Cap-&gt;new;
my $desc = $mc-&gt;description('image/gif');
print &quot;GIF desc: $desc\n&quot;;
my $cmd = $mc-&gt;viewCmd('text/plain; charset=iso-8859-1', 'file.txt');
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Parse mailcap files as specified in &quot;<FONT SIZE="-1">RFC 1524</FONT> --A User Agent
Configuration Mechanism For Multimedia Mail Format Information&gt;. In
the description below <TT>$type</TT> refers to the <FONT SIZE="-1">MIME</FONT> type as specified in
the <TT>&quot;Content-Type&quot;</TT> header of mail or <FONT SIZE="-1">HTTP</FONT> messages. Examples of
types are:
<P>
<PRE>
image/gif
text/html
text/plain; charset=iso-8859-1
</PRE>
<P>
You could also take a look at the File::MimeInfo distribution, which
are accessing tables which are used by many applications on a system,
and therefore have succeeded the mail-cap specifications on modern
(<FONT SIZE="-1">UNIX</FONT>) systems.
<A NAME="lbAE">&nbsp;</A>
<H2>METHODS</H2>
<A NAME="lbAF">&nbsp;</A>
<H3>Constructors</H3>
<DL COMPACT>
<DT id="1">Mail::Cap-&gt;<B>new</B>(%options)<DD>
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 <FONT SIZE="-1">MAILCAPS</FONT> environment variable if it is defined.
<P>
<PRE>
-Option --Default
filename undef
take 'FIRST'
</PRE>
<DL COMPACT><DT id="2"><DD>
<DL COMPACT>
<DT id="3">filename =&gt; <FONT SIZE="-1">FILENAME</FONT><DD>
Add the specified file to the list to standard locations. This file
is tried first.
<DT id="4">take =&gt; '<FONT SIZE="-1">ALL</FONT>'|'<FONT SIZE="-1">FIRST</FONT>'<DD>
Include all mailcap files you can find. By default, only the first
file is parsed, however the <FONT SIZE="-1">RFC</FONT> tells us to include <FONT SIZE="-1">ALL.</FONT> To maintain
backwards compatibility, the default only takes the <FONT SIZE="-1">FIRST.</FONT>
</DL>
</DL>
<DL COMPACT><DT id="5"><DD>
<P>
example:
<P>
<PRE>
$mcap = new Mail::Cap;
$mcap = new Mail::Cap &quot;/mydir/mailcap&quot;;
$mcap = new Mail::Cap filename =&gt; &quot;/mydir/mailcap&quot;;
$mcap = new Mail::Cap take =&gt; 'ALL';
$mcap = Mail::Cap-&gt;new(take =&gt; 'ALL');
</PRE>
</DL>
</DL>
<A NAME="lbAG">&nbsp;</A>
<H3>Run commands</H3>
These methods invoke a suitable program presenting or manipulating the
media object in the specified file. They all return <TT>1</TT> if a command
was found, and <TT>0</TT> otherwise. You might test <TT>$?</TT> for the outcome
of the command.
<DL COMPACT>
<DT id="6">$obj-&gt;<B>compose</B>($type, $file)<DD>
<DT id="7">$obj-&gt;<B>edit</B>($type, $file)<DD>
<DT id="8">$obj-&gt;<B>print</B>($type, $file)<DD>
<DT id="9">$obj-&gt;<B>view</B>($type, $file)<DD>
</DL>
<A NAME="lbAH">&nbsp;</A>
<H3>Command creator</H3>
These methods return a string that is suitable for feeding to <B>system()</B>
in order to invoke a suitable program presenting or manipulating the
media object in the specified file. It will return <TT>&quot;undef&quot;</TT> if no
suitable specification exists.
<DL COMPACT>
<DT id="10">$obj-&gt;<B>composeCmd</B>($type, $file)<DD>
<DT id="11">$obj-&gt;<B>editCmd</B>($type, $file)<DD>
<DT id="12">$obj-&gt;<B>printCmd</B>($type, $file)<DD>
<DT id="13">$obj-&gt;<B>viewCmd</B>($type, $file)<DD>
</DL>
<A NAME="lbAI">&nbsp;</A>
<H3>Look-up definitions</H3>
Methods return the corresponding mailcap field for the type.
<DL COMPACT>
<DT id="14">$obj-&gt;<B>description</B>($type)<DD>
<DT id="15">$obj-&gt;<B>field</B>($type, $field)<DD>
Returns the specified field for the type. Returns undef if no
specification exists.
<DT id="16">$obj-&gt;<B>nametemplate</B>($type)<DD>
<DT id="17">$obj-&gt;<B>textualnewlines</B>($type)<DD>
<DT id="18">$obj-&gt;<B>x11_bitmap</B>($type)<DD>
</DL>
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
This module is part of the MailTools distribution,
<I><A HREF="http://perl.overmeer.net/mailtools/">http://perl.overmeer.net/mailtools/</A></I>.
<A NAME="lbAK">&nbsp;</A>
<H2>AUTHORS</H2>
The MailTools bundle was developed by Graham Barr. Later, Mark
Overmeer took over maintenance without commitment to further development.
<P>
Mail::Cap by Gisle Aas &lt;<A HREF="mailto:aas@oslonett.no">aas@oslonett.no</A>&gt;.
Mail::Field::AddrList by Peter Orbaek &lt;<A HREF="mailto:poe@cit.dk">poe@cit.dk</A>&gt;.
Mail::Mailer and Mail::Send by Tim Bunce &lt;<A HREF="mailto:Tim.Bunce@ig.co.uk">Tim.Bunce@ig.co.uk</A>&gt;.
For other contributors see ChangeLog.
<A NAME="lbAL">&nbsp;</A>
<H2>LICENSE</H2>
Copyrights 1995-2000 Graham Barr &lt;<A HREF="mailto:gbarr@pobox.com">gbarr@pobox.com</A>&gt; and
2001-2017 Mark Overmeer &lt;<A HREF="mailto:perl@overmeer.net">perl@overmeer.net</A>&gt;.
<P>
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See <I><A HREF="http://www.perl.com/perl/misc/Artistic.html">http://www.perl.com/perl/misc/Artistic.html</A></I>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="19"><A HREF="#lbAB">NAME</A><DD>
<DT id="20"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="21"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="22"><A HREF="#lbAE">METHODS</A><DD>
<DL>
<DT id="23"><A HREF="#lbAF">Constructors</A><DD>
<DT id="24"><A HREF="#lbAG">Run commands</A><DD>
<DT id="25"><A HREF="#lbAH">Command creator</A><DD>
<DT id="26"><A HREF="#lbAI">Look-up definitions</A><DD>
</DL>
<DT id="27"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="28"><A HREF="#lbAK">AUTHORS</A><DD>
<DT id="29"><A HREF="#lbAL">LICENSE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:47 GMT, March 31, 2021
</BODY>
</HTML>