821 lines
No EOL
54 KiB
HTML
821 lines
No EOL
54 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 5. Mutt's MIME Support</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="home" href="index.html" title="The Mutt E-Mail Client" /><link rel="up" href="index.html" title="The Mutt E-Mail Client" /><link rel="prev" href="advancedusage.html" title="Chapter 4. Advanced Usage" /><link rel="next" href="optionalfeatures.html" title="Chapter 6. Optional Features" /><style xmlns="" type="text/css">
|
||
body { margin-left:2%; margin-right:2%; font-family:serif; }
|
||
.toc, .list-of-tables, .list-of-examples { font-family:sans-serif; }
|
||
h1, h2, h3, h4, h5, h6 { font-family:sans-serif; }
|
||
p { text-align:justify; }
|
||
div.table p.title, div.example p.title { font-size:smaller; font-family:sans-serif; }
|
||
.email, .email a { font-family:monospace; }
|
||
div.table-contents table, div.informaltable table { border-collapse:collapse; border:1px solid #c0c0c0; }
|
||
div.table-contents table td, div.informaltable td, div.table-contents table th, div.informaltable table th { padding:5px; text-align:left; }
|
||
div.table-contents table th, div.informaltable table th {
|
||
font-family:sans-serif;
|
||
background:#d0d0d0;
|
||
font-weight:normal;
|
||
vertical-align:top;
|
||
}
|
||
div.cmdsynopsis { border-left:1px solid #707070; padding-left:5px; }
|
||
li div.cmdsynopsis { border-left:none; padding-left:0px; }
|
||
pre.screen, div.note { background:#f0f0f0; border:1px solid #c0c0c0; padding:5px; margin-left:2%; margin-right:2%; }
|
||
div.example p.title { margin-left:2%; }
|
||
div.note h3 { font-size:small; font-style:italic; font-variant: small-caps; }
|
||
div.note h3:after { content: ":" }
|
||
div.note { margin-bottom: 5px; }
|
||
.command { font-family: monospace; font-weight: normal; }
|
||
.command strong { font-weight: normal; }
|
||
tr { vertical-align: top; }
|
||
.comment { color:#707070; }
|
||
|
||
</style></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Mutt's MIME Support</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="advancedusage.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="optionalfeatures.html">Next</a></td></tr></table><hr /></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a id="mimesupport"></a>Chapter 5. Mutt's MIME Support</h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="mimesupport.html#using-mime">1. Using MIME in Mutt</a></span></dt><dd><dl><dt><span class="sect2"><a href="mimesupport.html#mime-overview">1.1. MIME Overview</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#mime-pager">1.2. Viewing MIME Messages in the Pager</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#attach-menu">1.3. The Attachment Menu</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#compose-menu">1.4. The Compose Menu</a></span></dt></dl></dd><dt><span class="sect1"><a href="mimesupport.html#mime-types">2. MIME Type Configuration with <code class="literal">mime.types</code></a></span></dt><dt><span class="sect1"><a href="mimesupport.html#mailcap">3. MIME Viewer Configuration with Mailcap</a></span></dt><dd><dl><dt><span class="sect2"><a href="mimesupport.html#mailcap-basics">3.1. The Basics of the Mailcap File</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#secure-mailcap">3.2. Secure Use of Mailcap</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#advanced-mailcap">3.3. Advanced Mailcap Usage</a></span></dt><dt><span class="sect2"><a href="mimesupport.html#mailcap-example">3.4. Example Mailcap Files</a></span></dt></dl></dd><dt><span class="sect1"><a href="mimesupport.html#auto-view">4. MIME Autoview</a></span></dt><dt><span class="sect1"><a href="mimesupport.html#alternative-order">5. MIME Multipart/Alternative</a></span></dt><dt><span class="sect1"><a href="mimesupport.html#attachments">6. Attachment Searching and Counting</a></span></dt><dt><span class="sect1"><a href="mimesupport.html#mime-lookup">7. MIME Lookup</a></span></dt></dl></div><p>
|
||
Quite a bit of effort has been made to make Mutt the premier text-mode
|
||
MIME MUA. Every effort has been made to provide the functionality that
|
||
the discerning MIME user requires, and the conformance to the standards
|
||
wherever possible. When configuring Mutt for MIME, there are two extra
|
||
types of configuration files which Mutt uses. One is the
|
||
<code class="literal">mime.types</code> file, which contains the mapping of file
|
||
extensions to IANA MIME types. The other is the
|
||
<code class="literal">mailcap</code> file, which specifies the external commands
|
||
to use for handling specific MIME types.
|
||
</p><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="using-mime"></a>1. Using MIME in Mutt</h2></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="mime-overview"></a>1.1. MIME Overview</h3></div></div></div><p>
|
||
MIME is short for <span class="quote">“<span class="quote">Multipurpose Internet Mail Extension</span>”</span>
|
||
and describes mechanisms to internationalize and structure mail
|
||
messages. Before the introduction of MIME, messages had a single text
|
||
part and were limited to us-ascii header and content. With MIME,
|
||
messages can have attachments (and even attachments which itself have
|
||
attachments and thus form a tree structure), nearly arbitrary characters
|
||
can be used for sender names, recipients and subjects.
|
||
</p><p>
|
||
Besides the handling of non-ascii characters in message headers, to Mutt
|
||
the most important aspect of MIME are so-called MIME types. These are
|
||
constructed using a <span class="emphasis"><em>major</em></span> and
|
||
<span class="emphasis"><em>minor</em></span> type separated by a forward slash. These
|
||
specify details about the content that follows. Based upon these, Mutt
|
||
decides how to handle this part. The most popular major type is
|
||
<span class="quote">“<span class="quote"><code class="literal">text</code></span>”</span> with minor types for plain text,
|
||
HTML and various other formats. Major types also exist for images,
|
||
audio, video and of course general application data (e.g. to separate
|
||
cryptographically signed data with a signature, send office documents,
|
||
and in general arbitrary binary data). There's also the
|
||
<code class="literal">multipart</code> major type which represents the root of a
|
||
subtree of MIME parts. A list of supported MIME types can be found in
|
||
<a class="xref" href="mimesupport.html#supported-mime-types" title="Table 5.1. Supported MIME types">Table 5.1, “Supported MIME types”</a>.
|
||
</p><p>
|
||
MIME also defines a set of encoding schemes for transporting MIME
|
||
content over the network: <code class="literal">7bit</code>,
|
||
<code class="literal">8bit</code>, <code class="literal">quoted-printable</code>,
|
||
<code class="literal">base64</code> and <code class="literal">binary</code>. There're some
|
||
rules when to choose what for encoding headers and/or body (if needed),
|
||
and Mutt will in general make a good choice.
|
||
</p><p>
|
||
Mutt does most of MIME encoding/decoding behind the scenes to form
|
||
messages conforming to MIME on the sending side. On reception, it can be
|
||
flexibly configured as to how what MIME structure is displayed (and if
|
||
it's displayed): these decisions are based on the content's MIME type.
|
||
There are three areas/menus in dealing with MIME: the pager (while
|
||
viewing a message), the attachment menu and the compose menu.
|
||
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="mime-pager"></a>1.2. Viewing MIME Messages in the Pager</h3></div></div></div><p>
|
||
When you select a message from the index and view it in the pager, Mutt
|
||
decodes as much of a message as possible to a text representation. Mutt
|
||
internally supports a number of MIME types, including the
|
||
<code class="literal">text</code> major type (with all minor types), the
|
||
<code class="literal">message/rfc822</code> (mail messages) type and some
|
||
<code class="literal">multipart</code> types. In addition, it recognizes a variety
|
||
of PGP MIME types, including PGP/MIME and
|
||
<code class="literal">application/pgp</code>.
|
||
</p><p>
|
||
Mutt will denote attachments with a couple lines describing them.
|
||
These lines are of the form:
|
||
</p><pre class="screen">
|
||
[-- Attachment #1: Description --]
|
||
[-- Type: text/plain, Encoding: 7bit, Size: 10000 --]
|
||
</pre><p>
|
||
Where the <span class="emphasis"><em>Description</em></span> is the description or
|
||
filename given for the attachment, and the <span class="emphasis"><em>Encoding</em></span>
|
||
is one of the already mentioned content encodings.
|
||
</p><p>
|
||
If Mutt cannot deal with a MIME type, it will display a message like:
|
||
</p><pre class="screen">
|
||
[-- image/gif is unsupported (use 'v' to view this part) --]
|
||
</pre></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="attach-menu"></a>1.3. The Attachment Menu</h3></div></div></div><p>
|
||
The default binding for <code class="literal"><view-attachments></code> is
|
||
<span class="quote">“<span class="quote">v</span>”</span>, which displays the attachment menu for a message. The
|
||
attachment menu displays a list of the attachments in a message. From
|
||
the attachment menu, you can save, print, pipe, delete, and view
|
||
attachments. You can apply these operations to a group of attachments
|
||
at once, by tagging the attachments and by using the
|
||
<code class="literal"><tag-prefix></code> operator. You can also reply to
|
||
the current message from this menu, and only the current attachment (or
|
||
the attachments tagged) will be quoted in your reply. You can view
|
||
attachments as text, or view them using the mailcap viewer definition
|
||
(the mailcap mechanism is explained later in detail).
|
||
</p><p>
|
||
Finally, you can apply the usual message-related functions (like <a class="link" href="gettingstarted.html#resend-message"><code class="literal"><resend-message></code></a>,
|
||
and the <code class="literal"><reply></code> and
|
||
<code class="literal"><forward></code> functions) to attachments of type
|
||
<code class="literal">message/rfc822</code>.
|
||
</p><p>
|
||
See table <a class="xref" href="reference.html#tab-attachment-bindings" title="Table 9.7. Default Attachment Menu Bindings">Table 9.7, “Default Attachment Menu Bindings”</a> for all available
|
||
functions.
|
||
</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="attach-viewers"></a>1.3.1. Viewing Attachments</h4></div></div></div><p>
|
||
There are four(!) ways of viewing attachments, so the functions
|
||
deserve some extra explanation.
|
||
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
|
||
<code class="literal"><view-mailcap></code>
|
||
(default keybinding: m)
|
||
</span></dt><dd><p>
|
||
This will use the first matching mailcap entry.
|
||
</p><p>
|
||
If no matching mailcap entries are found, it will abort with an
|
||
error message.
|
||
</p></dd><dt><span class="term">
|
||
<code class="literal"><view-attach></code>
|
||
(default keybinding: <Enter>)
|
||
</span></dt><dd><p>
|
||
Mutt will display internally supported MIME types (see <a class="xref" href="mimesupport.html#mime-pager" title="1.2. Viewing MIME Messages in the Pager">Section 1.2, “Viewing MIME Messages in the Pager”</a>) in the pager. This will respect
|
||
<a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview">auto_view</a> settings, to determine
|
||
whether to use a <code class="literal">copiousoutput</code> mailcap entry or
|
||
just directly display the attachment.
|
||
</p><p>
|
||
Other MIME types will use the first matching mailcap entry.
|
||
</p><p>
|
||
If no matching mailcap entries are found, the attachment will
|
||
be displayed in the pager as raw text.
|
||
</p></dd><dt><span class="term">
|
||
<code class="literal"><view-pager></code>
|
||
</span></dt><dd><p>
|
||
Mutt will use the first matching
|
||
<code class="literal">copiousoutput</code> mailcap entry to display the
|
||
attachment in the pager (regardless of <a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview">auto_view</a> settings).
|
||
</p><p>
|
||
If no matching mailcap entries are found, the attachment will
|
||
be displayed in the pager as raw text.
|
||
</p></dd><dt><span class="term">
|
||
<code class="literal"><view-text></code>
|
||
(default keybinding: T)
|
||
</span></dt><dd><p>
|
||
The attachment will always be displayed in the pager as raw
|
||
text.
|
||
</p></dd></dl></div></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="compose-menu"></a>1.4. The Compose Menu</h3></div></div></div><p>
|
||
The compose menu is the menu you see before you send a message. It
|
||
allows you to edit the recipient list, the subject, and other aspects of
|
||
your message. It also contains a list of the attachments of your
|
||
message, including the main body. From this menu, you can print, copy,
|
||
filter, pipe, edit, compose, review, and rename an attachment or a list
|
||
of tagged attachments. You can also modifying the attachment
|
||
information, notably the type, encoding and description.
|
||
</p><p>
|
||
Attachments appear as follows by default:
|
||
</p><pre class="screen">
|
||
- 1 [text/plain, 7bit, 1K] /tmp/mutt-euler-8082-0 <no description>
|
||
2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz <no description>
|
||
</pre><p>
|
||
The <span class="quote">“<span class="quote">-</span>”</span> denotes that Mutt will delete the file after
|
||
sending (or postponing, or canceling) the message. It can be toggled
|
||
with the <code class="literal"><toggle-unlink></code> command (default: u).
|
||
The next field is the MIME content-type, and can be changed with the
|
||
<code class="literal"><edit-type></code> command (default: ^T). The next
|
||
field is the encoding for the attachment, which allows a binary message
|
||
to be encoded for transmission on 7bit links. It can be changed with
|
||
the <code class="literal"><edit-encoding></code> command (default: ^E). The
|
||
next field is the size of the attachment, rounded to kilobytes or
|
||
megabytes. The next field is the filename, which can be changed with
|
||
the <code class="literal"><rename-file></code> command (default: R). The
|
||
final field is the description of the attachment, and can be changed
|
||
with the <code class="literal"><edit-description></code> command (default:
|
||
d). See <a class="link" href="reference.html#attach-format" title="3.15. attach_format">$attach_format</a> for a full
|
||
list of available expandos to format this display to your needs.
|
||
</p></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="mime-types"></a>2. MIME Type Configuration with <code class="literal">mime.types</code></h2></div></div></div><p>
|
||
To get most out of MIME, it's important that a MIME part's content type
|
||
matches the content as closely as possible so that the recipient's
|
||
client can automatically select the right viewer for the
|
||
content. However, there's no reliable way for Mutt to know how to detect
|
||
every possible file type. Instead, it uses a simple plain text mapping
|
||
file that specifies what file extension corresponds to what MIME
|
||
type. This file is called <code class="literal">mime.types</code>.
|
||
</p><p>
|
||
When you add an attachment to your mail message, Mutt searches your
|
||
personal <code class="literal">mime.types</code> file at
|
||
<code class="literal">$HOME/.mime.types</code>, and then the system
|
||
<code class="literal">mime.types</code> file at
|
||
<code class="literal">/usr/local/share/mutt/mime.types</code> or
|
||
<code class="literal">/etc/mime.types</code>
|
||
</p><p>
|
||
Each line starts with the full MIME type, followed by a space and
|
||
space-separated list of file extensions. For example you could use:
|
||
</p><div class="example"><a id="ex-mime-types"></a><p class="title"><strong>Example 5.1. <code class="literal">mime.types</code></strong></p><div class="example-contents"><pre class="screen">
|
||
application/postscript ps eps
|
||
application/pgp pgp
|
||
audio/x-aiff aif aifc aiff
|
||
</pre></div></div><br class="example-break" /><p>
|
||
A sample <code class="literal">mime.types</code> file comes with the Mutt
|
||
distribution, and should contain most of the MIME types you are likely
|
||
to use.
|
||
</p><p>
|
||
If Mutt can not determine the MIME type by the extension of the file you
|
||
attach, it will run the command specified in
|
||
<a class="link" href="reference.html#mime-type-query-command" title="3.196. mime_type_query_command">$mime_type_query_command</a>.
|
||
If that command is not specified, Mutt will look at the file. If the file
|
||
is free of binary information, Mutt will assume that the file is plain text,
|
||
and mark it as <code class="literal">text/plain</code>. If the file contains binary
|
||
information, then Mutt will mark it as
|
||
<code class="literal">application/octet-stream</code>. You can change the MIME
|
||
type that Mutt assigns to an attachment by using the
|
||
<code class="literal"><edit-type></code> command from the compose menu
|
||
(default: ^T), see <a class="xref" href="mimesupport.html#supported-mime-types" title="Table 5.1. Supported MIME types">Table 5.1, “Supported MIME types”</a> for supported
|
||
major types. Mutt recognizes all of these if the appropriate entry is
|
||
found in the <code class="literal">mime.types</code> file. Non-recognized mime
|
||
types should only be used if the recipient of the message is likely to
|
||
be expecting such attachments.
|
||
</p><div class="table"><a id="supported-mime-types"></a><p class="title"><strong>Table 5.1. Supported MIME types</strong></p><div class="table-contents"><table class="table" summary="Supported MIME types" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>MIME major type</th><th>Standard</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">application</code></td><td>yes</td><td>General application data</td></tr><tr><td><code class="literal">audio</code></td><td>yes</td><td>Audio data</td></tr><tr><td><code class="literal">image</code></td><td>yes</td><td>Image data</td></tr><tr><td><code class="literal">message</code></td><td>yes</td><td>Mail messages, message status information</td></tr><tr><td><code class="literal">model</code></td><td>yes</td><td>VRML and other modeling data</td></tr><tr><td><code class="literal">multipart</code></td><td>yes</td><td>Container for other MIME parts</td></tr><tr><td><code class="literal">text</code></td><td>yes</td><td>Text data</td></tr><tr><td><code class="literal">video</code></td><td>yes</td><td>Video data</td></tr><tr><td><code class="literal">chemical</code></td><td>no</td><td>Mostly molecular data</td></tr></tbody></table></div></div><br class="table-break" /><p>
|
||
MIME types are not arbitrary, they need to be assigned by <a class="ulink" href="http://www.iana.org/assignments/media-types/" target="_top">IANA</a>.
|
||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="mailcap"></a>3. MIME Viewer Configuration with Mailcap</h2></div></div></div><p>
|
||
Mutt supports RFC 1524 MIME Configuration, in particular the Unix
|
||
specific format specified in Appendix A of RFC 1524. This file format
|
||
is commonly referred to as the <span class="quote">“<span class="quote">mailcap</span>”</span> format. Many MIME
|
||
compliant programs utilize the mailcap format, allowing you to specify
|
||
handling for all MIME types in one place for all programs. Programs
|
||
known to use this format include Firefox, lynx and metamail.
|
||
</p><p>
|
||
In order to handle various MIME types that Mutt doesn't have built-in
|
||
support for, it parses a series of external configuration files to find
|
||
an external handler. The default search string for these files is a
|
||
colon delimited list containing the following files:
|
||
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p><code class="literal">$HOME/.mailcap</code></p></li><li class="listitem"><p><code class="literal">$PKGDATADIR/mailcap</code></p></li><li class="listitem"><p><code class="literal">$SYSCONFDIR/mailcap</code></p></li><li class="listitem"><p><code class="literal">/etc/mailcap</code></p></li><li class="listitem"><p><code class="literal">/usr/etc/mailcap</code></p></li><li class="listitem"><p><code class="literal">/usr/local/etc/mailcap</code></p></li></ol></div><p>
|
||
where <code class="literal">$HOME</code> is your home directory. The
|
||
<code class="literal">$PKGDATADIR</code> and the <code class="literal">$SYSCONFDIR</code>
|
||
directories depend on where Mutt is installed: the former is the default
|
||
for shared data, the latter for system configuration files.
|
||
</p><p>
|
||
The default search path can be obtained by running the following
|
||
command:
|
||
</p><pre class="screen">
|
||
mutt -nF /dev/null -Q mailcap_path
|
||
</pre><p>
|
||
In particular, the metamail distribution will install a mailcap file,
|
||
usually as <code class="literal">/usr/local/etc/mailcap</code>, which contains
|
||
some baseline entries.
|
||
</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="mailcap-basics"></a>3.1. The Basics of the Mailcap File</h3></div></div></div><p>
|
||
A mailcap file consists of a series of lines which are comments, blank,
|
||
or definitions.
|
||
</p><p>
|
||
A comment line consists of a # character followed by anything you want.
|
||
</p><p>
|
||
A blank line is blank.
|
||
</p><p>
|
||
A definition line consists of a content type, a view command, and any
|
||
number of optional fields. Each field of a definition line is divided
|
||
by a semicolon <span class="quote">“<span class="quote">;</span>”</span> character.
|
||
</p><p>
|
||
The content type is specified in the MIME standard
|
||
<span class="quote">“<span class="quote">type/subtype</span>”</span> notation. For example,
|
||
<code class="literal">text/plain</code>, <code class="literal">text/html</code>,
|
||
<code class="literal">image/gif</code>, etc. In addition, the mailcap format
|
||
includes two formats for wildcards, one using the special
|
||
<span class="quote">“<span class="quote">*</span>”</span> subtype, the other is the implicit wild, where you only
|
||
include the major type. For example, <code class="literal">image/*</code>, or
|
||
<code class="literal">video</code> will match all image types and video types,
|
||
respectively.
|
||
</p><p>
|
||
The view command is a Unix command for viewing the type specified. There
|
||
are two different types of commands supported. The default is to send
|
||
the body of the MIME message to the command on stdin. You can change
|
||
this behavior by using <code class="literal">%s</code> as a parameter to your view
|
||
command. This will cause Mutt to save the body of the MIME message to a
|
||
temporary file, and then call the view command with the
|
||
<code class="literal">%s</code> replaced by the name of the temporary file. In
|
||
both cases, Mutt will turn over the terminal to the view program until
|
||
the program quits, at which time Mutt will remove the temporary file if
|
||
it exists. This means that mailcap does <span class="emphasis"><em>not</em></span> work
|
||
out of the box with programs which detach themselves from the terminal
|
||
right after starting, like <code class="literal">open</code> on Mac OS X. In order
|
||
to nevertheless use these programs with mailcap, you probably need
|
||
custom shell scripts.
|
||
</p><p>
|
||
So, in the simplest form, you can send a <code class="literal">text/plain</code>
|
||
message to the external pager more on standard input:
|
||
</p><pre class="screen">
|
||
text/plain; more
|
||
</pre><p>
|
||
Or, you could send the message as a file:
|
||
</p><pre class="screen">
|
||
text/plain; more %s
|
||
</pre><p>
|
||
Perhaps you would like to use lynx to interactively view a
|
||
<code class="literal">text/html</code> message:
|
||
</p><pre class="screen">
|
||
text/html; lynx %s
|
||
</pre><p>
|
||
In this case, lynx does not support viewing a file from standard input,
|
||
so you must use the <code class="literal">%s</code> syntax.
|
||
</p><div class="note"><h3 class="title">Note</h3><p>
|
||
<span class="emphasis"><em>Some older versions of lynx contain a bug where they will
|
||
check the mailcap file for a viewer for <code class="literal">text/html</code>.
|
||
They will find the line which calls lynx, and run it. This causes lynx
|
||
to continuously spawn itself to view the object.</em></span>
|
||
</p></div><p>
|
||
On the other hand, maybe you don't want to use lynx interactively, you
|
||
just want to have it convert the <code class="literal">text/html</code> to
|
||
<code class="literal">text/plain</code>, then you can use:
|
||
</p><pre class="screen">
|
||
text/html; lynx -dump %s | more
|
||
</pre><p>
|
||
Perhaps you wish to use lynx to view <code class="literal">text/html</code> files,
|
||
and a pager on all other text formats, then you would use the following:
|
||
</p><pre class="screen">
|
||
text/html; lynx %s
|
||
text/*; more
|
||
</pre></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="secure-mailcap"></a>3.2. Secure Use of Mailcap</h3></div></div></div><p>
|
||
The interpretation of shell meta-characters embedded in MIME parameters
|
||
can lead to security problems in general. Mutt tries to quote
|
||
parameters in expansion of <code class="literal">%s</code> syntaxes properly, and
|
||
avoids risky characters by substituting them, see the <a class="link" href="reference.html#mailcap-sanitize" title="3.170. mailcap_sanitize">$mailcap_sanitize</a> variable.
|
||
</p><p>
|
||
Although Mutt's procedures to invoke programs with mailcap seem to be
|
||
safe, there are other applications parsing mailcap, maybe taking less
|
||
care of it. Therefore you should pay attention to the following rules:
|
||
</p><p>
|
||
<span class="emphasis"><em>Keep the %-expandos away from shell quoting.</em></span> Don't
|
||
quote them with single or double quotes. Mutt does this for you, the
|
||
right way, as should any other program which interprets mailcap. Don't
|
||
put them into backtick expansions. Be highly careful with evil
|
||
statements, and avoid them if possible at all. Trying to fix broken
|
||
behavior with quotes introduces new leaks — there is no
|
||
alternative to correct quoting in the first place.
|
||
</p><p>
|
||
If you have to use the %-expandos' values in context where you need
|
||
quoting or backtick expansions, put that value into a shell variable and
|
||
reference the shell variable where necessary, as in the following
|
||
example (using <code class="literal">$charset</code> inside the backtick expansion
|
||
is safe, since it is not itself subject to any further expansion):
|
||
</p><pre class="screen">
|
||
text/test-mailcap-bug; cat %s; copiousoutput; test=charset=%{charset} \
|
||
&& test "`echo $charset | tr '[A-Z]' '[a-z]'`" != iso-8859-1
|
||
</pre></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="advanced-mailcap"></a>3.3. Advanced Mailcap Usage</h3></div></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="optional-mailcap-fields"></a>3.3.1. Optional Fields</h4></div></div></div><p>
|
||
In addition to the required content-type and view command fields, you
|
||
can add semi-colon <span class="quote">“<span class="quote">;</span>”</span> separated fields to set flags and
|
||
other options. Mutt recognizes the following optional fields:
|
||
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">copiousoutput</span></dt><dd><p>
|
||
This flag tells Mutt that the command passes possibly large amounts of
|
||
text on standard output. This causes Mutt to invoke a pager (either
|
||
the internal pager or the external pager defined by the pager variable)
|
||
on the output of the view command. Without this flag, Mutt assumes that
|
||
the command is interactive. One could use this to replace the pipe to
|
||
<code class="literal">more</code> in the <code class="literal">lynx -dump</code> example in
|
||
the Basic section:
|
||
</p><pre class="screen">
|
||
text/html; lynx -dump %s ; copiousoutput
|
||
</pre><p>
|
||
This will cause lynx to format the <code class="literal">text/html</code> output
|
||
as <code class="literal">text/plain</code> and Mutt will use your standard pager
|
||
to display the results.
|
||
</p><p>
|
||
Mutt will set the <code class="literal">COLUMNS</code> environment variable to
|
||
the width of the pager. Some programs make use of this environment
|
||
variable automatically. Others provide a command line argument that
|
||
can use this to set the output width:
|
||
</p><pre class="screen">
|
||
text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput
|
||
</pre><p>
|
||
Note that when using the built-in pager, <span class="emphasis"><em>only</em></span>
|
||
entries with this flag will be considered a handler for a MIME type
|
||
— all other entries will be ignored.
|
||
</p></dd><dt><span class="term">needsterminal</span></dt><dd><p>
|
||
Mutt uses this flag when viewing attachments with <a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview"><span class="command"><strong>auto_view</strong></span></a>, in order to
|
||
decide whether it should honor the setting of the <a class="link" href="reference.html#wait-key" title="3.416. wait_key">$wait_key</a> variable or not. When an attachment
|
||
is viewed using an interactive program, and the corresponding mailcap
|
||
entry has a <span class="emphasis"><em>needsterminal</em></span> flag, Mutt will use <a class="link" href="reference.html#wait-key" title="3.416. wait_key">$wait_key</a> and the exit status of the program
|
||
to decide if it will ask you to press a key after the external program
|
||
has exited. In all other situations it will not prompt you for a key.
|
||
</p></dd><dt><span class="term">compose=<command></span></dt><dd><p>
|
||
This flag specifies the command to use to create a new attachment of a
|
||
specific MIME type. Mutt supports this from the compose menu.
|
||
</p></dd><dt><span class="term">composetyped=<command></span></dt><dd><p>
|
||
This flag specifies the command to use to create a new attachment of a
|
||
specific MIME type. This command differs from the compose command in
|
||
that Mutt will expect standard MIME headers on the data. This can be
|
||
used to specify parameters, filename, description, etc. for a new
|
||
attachment. Mutt supports this from the compose menu.
|
||
</p></dd><dt><span class="term">print=<command></span></dt><dd><p>
|
||
This flag specifies the command to use to print a specific MIME type.
|
||
Mutt supports this from the attachment and compose menus.
|
||
</p></dd><dt><span class="term">edit=<command></span></dt><dd><p>
|
||
This flag specifies the command to use to edit a specific MIME type.
|
||
Mutt supports this from the compose menu, and also uses it to compose
|
||
new attachments. Mutt will default to the defined <a class="link" href="reference.html#editor" title="3.85. editor">$editor</a> for text attachments.
|
||
</p></dd><dt><span class="term">nametemplate=<template></span></dt><dd><p>
|
||
This field specifies the format for the file denoted by
|
||
<code class="literal">%s</code> in the command fields. Certain programs will
|
||
require a certain file extension, for instance, to correctly view a
|
||
file. For instance, lynx will only interpret a file as
|
||
<code class="literal">text/html</code> if the file ends in
|
||
<code class="literal">.html</code>. So, you would specify lynx as a
|
||
<code class="literal">text/html</code> viewer with a line in the mailcap file
|
||
like:
|
||
</p><pre class="screen">
|
||
text/html; lynx %s; nametemplate=%s.html
|
||
</pre></dd><dt><span class="term">test=<command></span></dt><dd><p>
|
||
This field specifies a command to run to test whether this mailcap entry
|
||
should be used. The command is defined with the command expansion rules
|
||
defined in the next section. If the command returns 0, then the test
|
||
passed, and Mutt uses this entry. If the command returns non-zero, then
|
||
the test failed, and Mutt continues searching for the right entry. Note
|
||
that the content-type must match before Mutt performs the test. For
|
||
example:
|
||
</p><pre class="screen">
|
||
text/html; firefox -remote 'openURL(%s)' ; test=RunningX
|
||
text/html; lynx %s
|
||
</pre><p>
|
||
In this example, Mutt will run the program <code class="literal">RunningX</code>
|
||
which will return 0 if the X Window manager is running, and non-zero if
|
||
it isn't. If <code class="literal">RunningX</code> returns 0, then Mutt will run
|
||
firefox to display the <code class="literal">text/html</code> object. If RunningX
|
||
doesn't return 0, then Mutt will go on to the next entry and use lynx to
|
||
display the <code class="literal">text/html</code> object.
|
||
</p></dd></dl></div></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="mailcap-search-order"></a>3.3.2. Search Order</h4></div></div></div><p>
|
||
When searching for an entry in the mailcap file, Mutt will search for
|
||
the most useful entry for its purpose. For instance, if you are
|
||
attempting to print an <code class="literal">image/gif</code>, and you have the
|
||
following entries in your mailcap file, Mutt will search for an entry
|
||
with the print command:
|
||
</p><pre class="screen">
|
||
image/*; xv %s
|
||
image/gif; ; print= anytopnm %s | pnmtops | lpr; \
|
||
nametemplate=%s.gif
|
||
</pre><p>
|
||
Mutt will skip the <code class="literal">image/*</code> entry and use the
|
||
<code class="literal">image/gif</code> entry with the print command.
|
||
</p><p>
|
||
In addition, you can use this with <a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview"><span class="command"><strong>auto_view</strong></span></a> to denote two
|
||
commands for viewing an attachment, one to be viewed automatically, the
|
||
other to be viewed interactively from the attachment menu using the
|
||
<code class="literal"><view-mailcap></code> function (bound to
|
||
<span class="quote">“<span class="quote">m</span>”</span> by default). In addition, you can then use the test
|
||
feature to determine which viewer to use interactively depending on your
|
||
environment.
|
||
</p><pre class="screen">
|
||
text/html; firefox -remote 'openURL(%s)' ; test=RunningX
|
||
text/html; lynx %s; nametemplate=%s.html
|
||
text/html; lynx -dump %s; nametemplate=%s.html; copiousoutput
|
||
</pre><p>
|
||
For <a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview"><span class="command"><strong>auto_view</strong></span></a>, Mutt
|
||
will choose the third entry because of the
|
||
<code class="literal">copiousoutput</code> tag. For interactive viewing, Mutt
|
||
will run the program <code class="literal">RunningX</code> to determine if it
|
||
should use the first entry. If the program returns non-zero, Mutt will
|
||
use the second entry for interactive viewing. The last entry is for
|
||
inline display in the pager and the
|
||
<code class="literal"><view-attach></code> function in the attachment menu.
|
||
</p><p>
|
||
Entries with the <code class="literal">copiousoutput</code> tag should always be
|
||
specified as the last one per type. For non-interactive use, the last
|
||
entry will then actually be the first matching one with the tag set.
|
||
For non-interactive use, only <code class="literal">copiousoutput</code>-tagged
|
||
entries are considered. For interactive use, Mutt ignores this tag and
|
||
treats all entries equally. Therefore, if not specified last, all
|
||
following entries without this tag would never be considered for
|
||
<code class="literal"><view-attach></code> because the
|
||
<code class="literal">copiousoutput</code> before them matched already.
|
||
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="mailcap-command-expansion"></a>3.3.3. Command Expansion</h4></div></div></div><p>
|
||
The various commands defined in the mailcap files are passed to the
|
||
<code class="literal">/bin/sh</code> shell using the <code class="literal">system(3)</code>
|
||
function. Before the command is passed to <code class="literal">/bin/sh
|
||
-c</code>, it is parsed to expand various special parameters with
|
||
information from Mutt. The keywords Mutt expands are:
|
||
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">%s</span></dt><dd><p>
|
||
As seen in the basic mailcap section, this variable is expanded to a
|
||
filename specified by the calling program. This file contains the body
|
||
of the message to view/print/edit or where the composing program should
|
||
place the results of composition. In addition, the use of this keyword
|
||
causes Mutt to not pass the body of the message to the view/print/edit
|
||
program on stdin.
|
||
</p></dd><dt><span class="term">%t</span></dt><dd><p>
|
||
Mutt will expand <code class="literal">%t</code> to the text representation of the
|
||
content type of the message in the same form as the first parameter of
|
||
the mailcap definition line, i.e. <code class="literal">text/html</code> or
|
||
<code class="literal">image/gif</code>.
|
||
</p></dd><dt><span class="term">%{<parameter>}</span></dt><dd><p>
|
||
Mutt will expand this to the value of the specified parameter from the
|
||
Content-Type: line of the mail message. For instance, if your mail
|
||
message contains:
|
||
</p><pre class="screen">
|
||
Content-Type: text/plain; charset=iso-8859-1
|
||
</pre><p>
|
||
then Mutt will expand <code class="literal">%{charset}</code> to
|
||
<span class="quote">“<span class="quote">iso-8859-1</span>”</span>. The default metamail mailcap file uses this
|
||
feature to test the charset to spawn an xterm using the right charset to
|
||
view the message.
|
||
</p></dd><dt><span class="term">\%</span></dt><dd><p>
|
||
This will be replaced by a literal <code class="literal">%</code>.
|
||
</p></dd></dl></div><p>
|
||
Mutt does not currently support the <code class="literal">%F</code> and
|
||
<code class="literal">%n</code> keywords specified in RFC 1524. The main purpose
|
||
of these parameters is for multipart messages, which is handled
|
||
internally by Mutt.
|
||
</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="mailcap-example"></a>3.4. Example Mailcap Files</h3></div></div></div><p>
|
||
This mailcap file is fairly simple and standard:
|
||
</p><pre class="screen">
|
||
<span class="comment"># I'm always running X :)</span>
|
||
video/*; xanim %s > /dev/null
|
||
image/*; xv %s > /dev/null
|
||
|
||
<span class="comment"># I'm always running firefox (if my computer had more memory, maybe)</span>
|
||
text/html; firefox -remote 'openURL(%s)'
|
||
</pre><p>
|
||
This mailcap file shows quite a number of examples:
|
||
</p><pre class="screen">
|
||
<span class="comment"># Use xanim to view all videos Xanim produces a header on startup,
|
||
# send that to /dev/null so I don't see it</span>
|
||
video/*; xanim %s > /dev/null
|
||
|
||
<span class="comment"># Send html to a running firefox by remote</span>
|
||
text/html; firefox -remote 'openURL(%s)'; test=RunningFirefox
|
||
|
||
<span class="comment"># If I'm not running firefox but I am running X, start firefox on the
|
||
# object</span>
|
||
text/html; firefox %s; test=RunningX
|
||
|
||
<span class="comment"># Else use lynx to view it as text</span>
|
||
text/html; lynx %s
|
||
|
||
<span class="comment"># This version would convert the text/html to text/plain</span>
|
||
text/html; lynx -dump %s; copiousoutput
|
||
|
||
<span class="comment"># I use enscript to print text in two columns to a page</span>
|
||
text/*; more %s; print=enscript -2Gr %s
|
||
|
||
<span class="comment"># Firefox adds a flag to tell itself to view jpegs internally</span>
|
||
image/jpeg;xv %s; x-mozilla-flags=internal
|
||
|
||
<span class="comment"># Use xv to view images if I'm running X</span>
|
||
<span class="comment"># In addition, this uses the \ to extend the line and set my editor</span>
|
||
<span class="comment"># for images</span>
|
||
image/*;xv %s; test=RunningX; \
|
||
edit=xpaint %s
|
||
|
||
<span class="comment"># Convert images to text using the netpbm tools</span>
|
||
image/*; (anytopnm %s | pnmscale -xysize 80 46 | ppmtopgm | pgmtopbm |
|
||
pbmtoascii -1x2 ) 2>&1 ; copiousoutput
|
||
|
||
<span class="comment"># Send excel spreadsheets to my NT box</span>
|
||
application/ms-excel; open.pl %s
|
||
</pre></div></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="auto-view"></a>4. MIME Autoview</h2></div></div></div><p>
|
||
Usage:
|
||
</p><div class="cmdsynopsis"><p><code class="command">auto_view</code>
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
[
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
...]<br /><code class="command">unauto_view</code> {
|
||
<em class="replaceable"><code>*</code></em>
|
||
|
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
... }</p></div><p>
|
||
In addition to explicitly telling Mutt to view an attachment with the
|
||
MIME viewer defined in the mailcap file from the attachments menu, Mutt
|
||
has support for automatically viewing MIME attachments while in the
|
||
pager.
|
||
</p><p>
|
||
For this to work, you must define a viewer in the mailcap file which
|
||
uses the <code class="literal">copiousoutput</code> option to denote that it is
|
||
non-interactive. Usually, you also use the entry to convert the
|
||
attachment to a text representation which you can view in the pager.
|
||
</p><p>
|
||
You then use the <span class="command"><strong>auto_view</strong></span> configuration command to
|
||
list the content-types that you wish to view automatically. For
|
||
instance, if you set it to:
|
||
</p><pre class="screen">
|
||
auto_view text/html application/x-gunzip \
|
||
application/postscript image/gif application/x-tar-gz
|
||
</pre><p>
|
||
...Mutt would try to find corresponding entries for rendering
|
||
attachments of these types as text. A corresponding mailcap could look
|
||
like:
|
||
</p><pre class="screen">
|
||
text/html; lynx -dump %s; copiousoutput; nametemplate=%s.html
|
||
image/*; anytopnm %s | pnmscale -xsize 80 -ysize 50 | ppmtopgm | \
|
||
pgmtopbm | pbmtoascii ; copiousoutput
|
||
application/x-gunzip; gzcat; copiousoutput
|
||
application/x-tar-gz; gunzip -c %s | tar -tf - ; copiousoutput
|
||
application/postscript; ps2ascii %s; copiousoutput
|
||
</pre><p>
|
||
<span class="command"><strong>unauto_view</strong></span> can be used to remove previous entries
|
||
from the <span class="command"><strong>auto_view</strong></span> list. This can be used with <a class="link" href="configuration.html#message-hook" title="22. Change Settings Before Formatting a Message"><span class="command"><strong>message-hook</strong></span></a> to
|
||
autoview messages based on size, etc.
|
||
<span class="quote">“<span class="quote"><span class="command"><strong>unauto_view</strong></span> *</span>”</span> will remove all previous
|
||
entries.
|
||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="alternative-order"></a>5. MIME Multipart/Alternative</h2></div></div></div><p>
|
||
The <code class="literal">multipart/alternative</code> container type only has
|
||
child MIME parts which represent the same content in an alternative
|
||
way. This is often used to send HTML messages which contain an
|
||
alternative plain text representation.
|
||
</p><p>
|
||
Mutt has some heuristics for determining which attachment of a
|
||
<code class="literal">multipart/alternative</code> type to display:
|
||
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
|
||
First, Mutt will check the <span class="command"><strong>alternative_order</strong></span> list to
|
||
determine if one of the available types is preferred. It consists of a
|
||
number of MIME types in order, including support for implicit and
|
||
explicit wildcards. For example:
|
||
</p><pre class="screen">
|
||
alternative_order text/enriched text/plain text \
|
||
application/postscript image/*
|
||
</pre></li><li class="listitem"><p>
|
||
Next, Mutt will check if any of the types have a defined <a class="link" href="mimesupport.html#auto-view" title="4. MIME Autoview"><span class="command"><strong>auto_view</strong></span></a>, and use that.
|
||
</p></li><li class="listitem"><p>
|
||
Failing that, Mutt will look first for
|
||
<code class="literal">text/enriched</code>, followed by
|
||
<code class="literal">text/plain</code>, and finally
|
||
<code class="literal">text/html</code>.
|
||
</p></li><li class="listitem"><p>
|
||
As a last attempt, Mutt will look for any type it knows how to handle.
|
||
</p></li></ol></div><p>
|
||
To remove a MIME type from the <span class="command"><strong>alternative_order</strong></span>
|
||
list, use the <span class="command"><strong>unalternative_order</strong></span> command.
|
||
</p><p>
|
||
Generating <code class="literal">multipart/alternative</code> content is supported
|
||
via the
|
||
<a class="link" href="reference.html#send-multipart-alternative" title="3.303. send_multipart_alternative">$send_multipart_alternative</a>
|
||
quadoption and
|
||
<a class="link" href="reference.html#send-multipart-alternative-filter" title="3.304. send_multipart_alternative_filter">$send_multipart_alternative_filter</a>
|
||
filter script. The composed <code class="literal">text/plain</code> content
|
||
will be piped to the filter script's stdin. The output from the
|
||
filter script should be the generated mime type of the content, a
|
||
blank line, and the content. For example:
|
||
</p><pre class="screen">
|
||
text/html
|
||
|
||
<html>
|
||
<body>
|
||
Content in html format
|
||
</body>
|
||
</html>
|
||
</pre><p>
|
||
A preview of the alternative can be viewed in the compose menu using
|
||
the functions <code class="literal"><view-alt></code> (bound to
|
||
"v"), <code class="literal"><view-alt-text></code> (bound to
|
||
"Esc v"), <code class="literal"><view-alt-mailcap></code> (bound
|
||
to "V"), and <code class="literal"><view-alt-pager></code>
|
||
(unbound). See <a class="xref" href="mimesupport.html#attach-viewers" title="1.3.1. Viewing Attachments">Section 1.3.1, “Viewing Attachments”</a> for a discussion of
|
||
the differences between these viewing functions.
|
||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="attachments"></a>6. Attachment Searching and Counting</h2></div></div></div><p>
|
||
If you ever lose track of attachments in your mailboxes, Mutt's
|
||
attachment-counting and -searching support might be for you. You can
|
||
make your message index display the number of qualifying attachments in
|
||
each message, or search for messages by attachment count. You also can
|
||
configure what kinds of attachments qualify for this feature with the
|
||
<span class="command"><strong>attachments</strong></span> and <span class="command"><strong>unattachments</strong></span>
|
||
commands.
|
||
</p><p>
|
||
In order to provide this information, Mutt needs to fully MIME-parse all
|
||
messages affected first. This can slow down operation especially for
|
||
remote mail folders such as IMAP because all messages have to be
|
||
downloaded first regardless whether the user really wants to view them
|
||
or not though using <a class="xref" href="optionalfeatures.html#body-caching" title="8.2. Body Caching">Section 8.2, “Body Caching”</a> usually means to
|
||
download the message just once.
|
||
</p><p>
|
||
By default, Mutt will not search inside
|
||
<code class="literal">multipart/alternative</code> containers. This can be
|
||
changed via the <a class="link" href="reference.html#count-alternatives" title="3.54. count_alternatives">$count_alternatives</a> configuration
|
||
variable.
|
||
</p><p>
|
||
The syntax is:
|
||
</p><div class="cmdsynopsis"><p><code class="command">attachments</code>
|
||
<em class="replaceable"><code>{ + | - }disposition</code></em>
|
||
|
||
<em class="replaceable"><code>mime-type</code></em>
|
||
<br /><code class="command">unattachments</code>
|
||
<em class="replaceable"><code>{ + | - }disposition</code></em>
|
||
|
||
<em class="replaceable"><code>mime-type</code></em>
|
||
<br /><code class="command">attachments</code>
|
||
<code class="option">?</code>
|
||
<br /><code class="command">unattachments</code>
|
||
<code class="option">*</code>
|
||
</p></div><p>
|
||
<span class="emphasis"><em>disposition</em></span> is the attachment's Content-Disposition
|
||
type — either <code class="literal">inline</code> or
|
||
<code class="literal">attachment</code>. You can abbreviate this to
|
||
<code class="literal">I</code> or <code class="literal">A</code>.
|
||
</p><p>
|
||
The first part of a message or multipart group, if inline, is counted
|
||
separately than other inline parts. Specify <code class="literal">root</code>
|
||
or <code class="literal">R</code> for <span class="emphasis"><em>disposition</em></span> to count
|
||
these as attachments. If this first part is of type
|
||
multipart/alternative, note that its top-level inline parts are also
|
||
counted via <code class="literal">root</code> <span class="emphasis"><em>disposition</em></span>
|
||
(if <a class="link" href="reference.html#count-alternatives" title="3.54. count_alternatives">$count_alternatives</a> is
|
||
set).
|
||
</p><p>
|
||
Disposition is prefixed by either a <span class="quote">“<span class="quote">+</span>”</span> symbol or a
|
||
<span class="quote">“<span class="quote">-</span>”</span> symbol. If it's a <span class="quote">“<span class="quote">+</span>”</span>, you're saying that
|
||
you want to allow this disposition and MIME type to qualify. If it's a
|
||
<span class="quote">“<span class="quote">-</span>”</span>, you're saying that this disposition and MIME type is
|
||
an exception to previous <span class="quote">“<span class="quote">+</span>”</span> rules. There are examples
|
||
below of how this is useful.
|
||
</p><p>
|
||
<span class="emphasis"><em>mime-type</em></span> is the MIME type of the attachment you
|
||
want the command to affect. A MIME type is always of the format
|
||
<code class="literal">major/minor</code>, where <code class="literal">major</code> describes
|
||
the broad category of document you're looking at, and
|
||
<code class="literal">minor</code> describes the specific type within that
|
||
category. The major part of mime-type must be literal text (or the
|
||
special token <span class="quote">“<span class="quote"><code class="literal">*</code></span>”</span>), but the minor part
|
||
may be a regular expression. (Therefore,
|
||
<span class="quote">“<span class="quote"><code class="literal">*/.*</code></span>”</span> matches any MIME type.)
|
||
</p><p>
|
||
The MIME types you give to the <span class="command"><strong>attachments</strong></span> directive
|
||
are a kind of pattern. When you use the <span class="command"><strong>attachments</strong></span>
|
||
directive, the patterns you specify are added to a list. When you use
|
||
<span class="command"><strong>unattachments</strong></span>, the pattern is removed from the list.
|
||
The patterns are not expanded and matched to specific MIME types at this
|
||
time — they're just text in a list. They're only matched when
|
||
actually evaluating a message.
|
||
</p><p>
|
||
Some examples might help to illustrate. The examples that are not
|
||
commented out define the default configuration of the lists.
|
||
</p><div class="example"><a id="ex-attach-count"></a><p class="title"><strong>Example 5.2. Attachment counting</strong></p><div class="example-contents"><pre class="screen">
|
||
<span class="comment">
|
||
# Removing a pattern from a list removes that pattern literally. It
|
||
# does not remove any type matching the pattern.
|
||
#
|
||
# attachments +A */.*
|
||
# attachments +A image/jpeg
|
||
# unattachments +A */.*
|
||
#
|
||
# This leaves "attached" image/jpeg files on the allowed attachments
|
||
# list. It does not remove all items, as you might expect, because the
|
||
# second */.* is not a matching expression at this time.
|
||
#
|
||
# Remember: "unattachments" only undoes what "attachments" has done!
|
||
# It does not trigger any matching on actual messages.
|
||
|
||
# Qualify any MIME part with an "attachment" disposition, EXCEPT for
|
||
# text/x-vcard and application/pgp parts. (PGP parts are already known
|
||
# to mutt, and can be searched for with ~g, ~G, and ~k.)
|
||
#
|
||
# I've added x-pkcs7 to this, since it functions (for S/MIME)
|
||
# analogously to PGP signature attachments. S/MIME isn't supported
|
||
# in a stock mutt build, but we can still treat it specially here.
|
||
#
|
||
</span>
|
||
attachments +A */.*
|
||
attachments -A text/x-vcard application/pgp.*
|
||
attachments -A application/x-pkcs7-.*
|
||
|
||
<span class="comment">
|
||
# Discount all MIME parts with an "inline" disposition, unless they're
|
||
# text/plain. (Why inline a text/plain part unless it's external to the
|
||
# message flow?)
|
||
</span>
|
||
attachments +I text/plain
|
||
|
||
<span class="comment">
|
||
# These two lines make Mutt qualify MIME containers. (So, for example,
|
||
# a message/rfc822 forward will count as an attachment.) The first
|
||
# line is unnecessary if you already have "attach-allow */.*", of
|
||
# course. These are off by default! The MIME elements contained
|
||
# within a message/* or multipart/* are still examined, even if the
|
||
# containers themselves don't qualify.
|
||
|
||
#attachments +A message/.* multipart/.*
|
||
#attachments +I message/.* multipart/.*
|
||
</span>
|
||
|
||
<span class="comment">## You probably don't really care to know about deleted attachments.</span>
|
||
attachments -A message/external-body
|
||
attachments -I message/external-body
|
||
</pre></div></div><br class="example-break" /><p>
|
||
Entering the command <span class="quote">“<span class="quote"><span class="command"><strong>attachments</strong></span> ?</span>”</span> as
|
||
a command will list your current settings in Muttrc format, so that it
|
||
can be pasted elsewhere.
|
||
</p><p>
|
||
Entering the command <span class="quote">“<span class="quote"><span class="command"><strong>unattachments</strong></span> *</span>”</span> as
|
||
a command will Clear all attachment settings.
|
||
</p></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="mime-lookup"></a>7. MIME Lookup</h2></div></div></div><p>
|
||
Usage:
|
||
</p><div class="cmdsynopsis"><p><code class="command">mime_lookup</code>
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
[
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
...]<br /><code class="command">unmime_lookup</code> {
|
||
<em class="replaceable"><code>*</code></em>
|
||
|
|
||
<em class="replaceable"><code>mimetype</code></em>
|
||
... }</p></div><p>
|
||
Mutt's <span class="command"><strong>mime_lookup</strong></span> list specifies a list of MIME
|
||
types that should <span class="emphasis"><em>not</em></span> be treated according to their
|
||
mailcap entry. This option is designed to deal with binary types such
|
||
as <code class="literal">application/octet-stream</code>. When an attachment's
|
||
MIME type is listed in <span class="command"><strong>mime_lookup</strong></span>, then the
|
||
extension of the filename will be compared to the list of extensions in
|
||
the <code class="literal">mime.types</code> file. The MIME type associated with
|
||
this extension will then be used to process the attachment according to
|
||
the rules in the mailcap file and according to any other configuration
|
||
options (such as <span class="command"><strong>auto_view</strong></span>) specified. Common usage
|
||
would be:
|
||
</p><pre class="screen">
|
||
mime_lookup application/octet-stream application/X-Lotus-Manuscript
|
||
</pre><p>
|
||
In addition, the <code class="literal">unmime_lookup</code> command may be used to
|
||
disable this feature for any particular MIME type if it had been set,
|
||
for example, in a global <code class="literal">.muttrc</code>.
|
||
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="advancedusage.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="optionalfeatures.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Advanced Usage </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Optional Features</td></tr></table></div></body></html> |