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  %  character.   (In
57       fact,  the  backslash  can  be  used  to quote any character, including
58       itself.)
59
60       If no "%s" appears in the command field, then instead  of  placing  the
61       message  body  in  a temporary file, metamail will pass the body to the
62       command on the standard input.  This is helpful  in  saving  /tmp  file
63       space,  but  can  be problematic for window-oriented applications under
64       some window systems such as MGR.
65
66       Two special codes can appear in the viewing command for objects of type
67       multipart (any subtype).  These are "%n" and "%F".  %n will be replaced
68       by the number of  parts  within  the  multipart  object.   %F  will  be
69       replaced  by a series of arguments, two for each part, giving first the
70       content-type and then the name of the temporary file where the  decoded
71       part has been stored.  In addition, for each file created by %F, a sec‐
72       ond file is created, with the same name followed by "H", which contains
73       the  header information for that body part.  This will not be needed by
74       most multipart handlers, but it is there if you ever need it.
75
76       The "notes=xxx" field is an uninterpreted string that is used to  spec‐
77       ify  the  name  of  the  person who installed this entry in the mailcap
78       file.  (The "xxx" may be replaced by any text string.)
79
80       The "test=xxx" field is a command that is executed to determine whether
81       or not the mailcap line actually applies.  That is, if the content-type
82       field matches the content-type on the message, but a "test="  field  is
83       present,  then the test must succeed before the mailcap line is consid‐
84       ered to "match" the message being viewed.  The command may be any  UNIX
85       command,  using the same syntax and the same %-escapes as for the view‐
86       ing command, as described above.  A command is considered to succeed if
87       it exits with a zero exit status, and to fail otherwise.
88
89       The  "print=xxx"  field is a command that is executed to print the data
90       instead of display it interactively.  This behavior is usually a conse‐
91       quence of invoking metamail with the "-h" switch.
92
93       The  "textualnewlines"  field  can  be  used in the rather obscure case
94       where metamail's default rules for treating newlines in  base64-encoded
95       data  are  unsatisfactory.  By default, metamail will translate CRLF to
96       the local newline character in decoded base64 output  if  the  content-
97       type  is "text" (any subtype), but will not do so otherwise.  A mailcap
98       entry with a field of "textualnewlines=1" will force  such  translation
99       for  the specified content-type, while "textualnewlines=0" will guaran‐
100       tee that the translation does not take place even for textual  content-
101       types.
102
103       The  "compose"  field may be used to specify a program that can be used
104       to compose a new body or body part in the given format.   Its  intended
105       use is to support mail composing agents that support the composition of
106       multiple types of mail using external composing  agents.  As  with  the
107       view-command, the compose command will be executed after replacing cer‐
108       tain escape sequences starting with "%".  In particular, %s  should  be
109       replaced  by  the  name  of  a file to which the composed data is to be
110       written by the specified composing program, thus allowing  the  calling
111       program  (e.g.  metamail) to tell the called program where to store the
112       composed data.  If %s does not appear, then the composed data  will  be
113       assumed  to  be  written  by the composing programs to standard output.
114       The result of the composing program may be data that is NOT  yet  suit‐
115       able  for  mail  transport  -- that is, a Content-Transfer-Encoding may
116       still need to be applied to the data.
117
118       The "composetyped" field is similar to the "compose" field, but  is  to
119       be  used  when  the composing program needs to specify the Content-type
120       header field to be applied to the composed data.  The  "compose"  field
121       is  simpler, and is preferred for use with existing (non-mail-oriented)
122       programs for composing data in  a  given  format.   The  "composetyped"
123       field  is necessary when the Content-type information must include aux‐
124       iliary parameters, and the composition program must  then  know  enough
125       about mail formats to produce output that includes the mail type infor‐
126       mation, and to apply any necessary Content-Transfer-Encoding.   Concep‐
127       tually, "compose" specifies a program that simply outputs the specified
128       type of data in its raw form, while "composetyped" specifies a  program
129       that  outputs  the  data as a MIME object, with all necessary Content-*
130       headers already in place.
131
132
133       needsterminal
134               If this flag is given, the named interpreter needs to  interact
135               with the user on a terminal.  In some environments (e.g. a win‐
136               dow-oriented mail reader under X11) this will require the  cre‐
137               ation  of  a new terminal emulation window, while in most envi‐
138               ronments it will not.  If the mailcap  entry  specifies  "need‐
139               sterminal" and metamail is not running on a terminal (as deter‐
140               mined by isatty(3), the -x option, and the  MM_NOTTTY  environ‐
141               ment  variable)  then metamail will try to run the command in a
142               new terminal emulation window.  Currently, metamail  knows  how
143               to  create  new  windows under the X11, SunTools, and WM window
144               systems.
145
146       copiousoutput
147               This flag should be given whenever the interpreter  is  capable
148               of  producing  more  than  a few lines of output on stdout, and
149               does no interaction with the user.  If the mailcap entry speci‐
150               fies  copiousoutput,  and pagination has been requested via the
151               "-p" command, then the output of  the  command  being  executed
152               will  be piped through a pagination program ("more" by default,
153               but this can be overridden with the METAMAIL_PAGER  environment
154               variable).
155

BUILT-IN CONTENT-TYPE SUPPORT

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

FILES

170       $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap  --
171       default path for mailcap files.
172

SEE ALSO

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

AUTHOR

190       Nathaniel S. Borenstein
191
192
193
194Bellcore Prototype                 Release 2                        MAILCAP(4)
Impressum