1MAILCAP(4)                 Kernel Interfaces Manual                 MAILCAP(4)
2
3
4

NAME

6       mailcap - metamail capabilities file
7

DESCRIPTION

9       The  mailcap  file  is read by the metamail program to determine how to
10       display non-text at the local site.
11
12       The syntax of a mailcap file is quite  simple,  at  least  compared  to
13       termcap  files.   Any  line  that  starts with "#" is a comment.  Blank
14       lines are ignored.  Otherwise, each line defines a single mailcap entry
15       for  a single content type.  Long lines may be continued by ending them
16       with a backslash character, \.
17
18       Each individual mailcap entry consists of a content-type specification,
19       a  command  to execute, and (possibly) a set of optional "flag" values.
20       For example, a very simple mailcap entry (which is actually a  built-in
21       default behavior for metamail) would look like this:
22
23       text/plain; cat %s
24
25       The  optional flags can be used to specify additional information about
26       the mail-handling command.  For example:
27
28       text/plain; cat %s; copiousoutput
29
30       can be used to indicate that the output of the  'cat'  command  may  be
31       voluminous, requiring either a scrolling window, a pager, or some other
32       appropriate coping mechanism.
33
34       The "type" field (text/plain, in the above example) is simply any legal
35       content  type name, as defined by RFC 822.  In practice, this is almost
36       any string.  It is the string that will be matched  against  the  "Con‐
37       tent-type" header (or the value passed in with -c) to decide if this is
38       the mailcap entry that matches the current message.  Additionally,  the
39       type field may specify a subtype (e.g. "text/ISO-8859-1") or a wildcard
40       to match all subtypes (e.g. "image/*").
41
42       The "command" field is any UNIX command ("cat %s" in  the  above  exam‐
43       ple), and is used to specify the interpreter for the given type of mes‐
44       sage.  It will be passed to  the  shell  via  the  system(3)  facility.
45       Semicolons and backslashes within the command must be quoted with back‐
46       slashes.  If the command contains "%s", those two  characters  will  be
47       replaced  by  the name of a file that contains the body of the message.
48       If it contains "%t', those two characters will be replaced by the  con‐
49       tent-type  field, including the subtype, if any.  (That is, if the con‐
50       tent-type was "image/pbm;  opt1=something-else",  then  "%t"  would  be
51       replaced  by  "image/pbm".)    If the command field contains  "%{" fol‐
52       lowed by a parameter name and a closing "}", then all those  characters
53       will  be replaced by the value of the named parameter, if any, from the
54       Content-type header.   Thus, in the previous example, "%{opt1}" will be
55       replaced  by  "something-else".   Finally,  if the command contains "",
56       those two characters will be replaced by a single % ch
57
58
59
60       aracter.  (In fact, the backslash can be used to quote  any  character,
61       including itself.)
62
63       If  no  "%s"  appears in the command field, then instead of placing the
64       message body in a temporary file, metamail will pass the  body  to  the
65       command  on  the  standard  input.  This is helpful in saving /tmp file
66       space, but can be problematic for  window-oriented  applications  under
67       some window systems such as MGR.
68
69       Two special codes can appear in the viewing command for objects of type
70       multipart (any subtype).  These are "%n" and "%F".  %n will be replaced
71       by  the  number  of  parts  within  the  multipart  object.  %F will be
72       replaced by a series of arguments, two for each part, giving first  the
73       content-type  and then the name of the temporary file where the decoded
74       part has been stored.  In addition, for each file created by %F, a sec‐
75       ond file is created, with the same name followed by "H", which contains
76       the header information for that body part.  This will not be needed  by
77       most multipart handlers, but it is there if you ever need it.
78
79       The  "notes=xxx" field is an uninterpreted string that is used to spec‐
80       ify the name of the person who installed  this  entry  in  the  mailcap
81       file.  (The "xxx" may be replaced by any text string.)
82
83       The "test=xxx" field is a command that is executed to determine whether
84       or not the mailcap line actually applies.  That is, if the content-type
85       field  matches  the content-type on the message, but a "test=" field is
86       present, then the test must succeed before the mailcap line is  consid‐
87       ered  to "match" the message being viewed.  The command may be any UNIX
88       command, using the same syntax and the same %-escapes as for the  view‐
89       ing command, as described above.  A command is considered to succeed if
90       it exits with a zero exit status, and to fail otherwise.
91
92       The "print=xxx" field is a command that is executed to print  the  data
93       instead of display it interactively.  This behavior is usually a conse‐
94       quence of invoking metamail with the "-h" switch.
95
96       The "textualnewlines" field can be used  in  the  rather  obscure  case
97       where  metamail's default rules for treating newlines in base64-encoded
98       data are unsatisfactory.  By default, metamail will translate  CRLF  to
99       the  local  newline  character in decoded base64 output if the content-
100       type is "text" (any subtype), but will not do so otherwise.  A  mailcap
101       entry  with  a field of "textualnewlines=1" will force such translation
102       for the specified content-type, while "textualnewlines=0" will  guaran‐
103       tee  that the translation does not take place even for textual content-
104       types.
105
106       The "compose" field may be used to specify a program that can  be  used
107       to  compose  a new body or body part in the given format.  Its intended
108       use is to support mail composing agents that support the composition of
109       multiple  types  of  mail  using external composing agents. As with the
110       view-command, the compose command will be executed after replacing cer‐
111       tain  escape  sequences starting with "%".  In particular, %s should be
112       replaced by the name of a file to which the  composed  data  is  to  be
113       written  by the specified composing program, thus allowing th3e calling
114       program (e.g. metamail) to tell the called program where to  store  the
115       composed  data.   If %s does not appear, then the composed data will be
116       assumed to be written by the composing  programs  to  standard  output.
117       The  result  of the composing program may be data that is NOT yet suit‐
118       able for mail transport -- that  is,  a  Content-Transfer-Encoding  may
119       still need to be applied to the data.
120
121       The  "composetyped"  field is similar to the "compose" field, but is to
122       be used when the composing program needs to  specify  the  Content-type
123       header  field  to be applied to the composed data.  The "compose" field
124       is simpler, and is preferred for use with existing  (non-mail-oriented)
125       programs  for  composing  data  in  a given format.  The "composetyped"
126       field is necessary when the Content-type information must include  aux‐
127       illiary  parameters,  and the composition program must then know enough
128       about mail formats to produce output that includes the mail type infor‐
129       mation, and to apply any necessary Content-Transfer-Encoding.   Concep‐
130       tually, "compose" specifies a program that simply outputs the specified
131       type  of data in its raw form, while "composetyped" specifies a program
132       that outputs the data as a MIME object, with  all  necessary  Content-*
133       headers already in place.
134
135
136       needsterminal
137               If  this flag is given, the named interpreter needs to interact
138               with the user on a terminal.  In some environments (e.g. a win‐
139               dow-oriented  mail reader under X11) this will require the cre‐
140               ation of a new terminal emulation window, while in  most  envi‐
141               ronments  it  will  not.  If the mailcap entry specifies "need‐
142               sterminal" and metamail is not running on a terminal (as deter‐
143               mined  by  isatty(3), the -x option, and the MM_NOTTTY environ‐
144               ment variable) then metamail will try to run the command  in  a
145               new  terminal  emulation window.  Currently, metamail knows how
146               to create new windows under the X11, SunTools,  and  WM  window
147               systems.
148
149       copiousoutput
150               This  flag  should be given whenever the interpreter is capable
151               of producing more than a few lines of  output  on  stdout,  and
152               does no interaction with the user.  If the mailcap entry speci‐
153               fies copiousoutput, and pagination has been requested  via  the
154               "-p"  command,  then  the  output of the command being executed
155               will be piped through a pagination program ("more" by  default,
156               but  this can be overridden with the METAMAIL_PAGER environment
157               variable).
158

BUILT-IN CONTENT-TYPE SUPPORT

160       The metamail program has built-in support for a few key  content-types.
161       In  particular,  it  supports  the  text type, the multipart and multi‐
162       part/alternative type, and the message/rfc822 types.  This  support  is
163       incomplete  for many subtypes -- for example, it only supports US-ASCII
164       text in general.  This kind of built-in support can be OVERRIDDEN by an
165       entry in any mailcap file on the user's search path.  Metamail also has
166       rudimentary built-in support for types that are totally unrecognized --
167       i.e.  for  which no mailcap entry or built-in handler exists.  For such
168       unrecognized types, metamail will write a file with a "clean"  copy  of
169       the  data  --  i.e. a copy in which all mail headers have been removed,
170       and in which any 7-bit transport encoding has been decoded.
171

FILES

173       $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap  --
174       default path for mailcap files.
175

SEE ALSO

177       metamail(1)
178
180       Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
181
182       Permission  to  use, copy, modify, and distribute this material for any
183       purpose and without fee is hereby  granted,  provided  that  the  above
184       copyright  notice  and this permission notice appear in all copies, and
185       that the name of Bellcore not be used in advertising or publicity  per‐
186       taining to this material without the specific, prior written permission
187       of an authorized representative of Bellcore.  BELLCORE MAKES NO  REPRE‐
188       SENTATIONS  ABOUT  THE ACCURACY OR SUITABILITY OF THIS MATERIAL FOR ANY
189       PURPOSE.  IT IS PROVIDED "AS IS", WITHOUT ANY EXPRESS OR  IMPLIED  WAR‐
190       RANTIES.
191

AUTHOR

193       Nathaniel S. Borenstein
194
195
196
197Bellcore Prototype                 Release 2                        MAILCAP(4)
Impressum