mailcap -- mail capabilities database


type[/subtype]; view-command [; keyword=key-command ... ]


The mail capabilities (mailcap) database file ($HOME/.mailcap or /usr/lib/scomail/mailcap) contains information on how different mail types can be handled by local printers, viewers, and players. Mail types that conform to RFC 822 and RFC 1521 (Multipurpose Internet Mail Extensions, MIME) are supported.

When scomail starts, it will first try to read the file .mailcap in the user's home directory. If that file does not exist, it will try to read /usr/lib/scomail/mailcap. If neither file exists, scomail searches /etc/mailcap, /usr/etc/mailcap, and /usr/local/etc/mailcap. The environment variable $MAILCAPS may be set to specify a different path to be searched for the mail capabilities file. For example:

Each mailcap file, whether system-wide or user-specific, has the same basic format. Each file consists of one or more entries, each of which describes how to handle one type of media at the local site. Entries are separated by one or more newlines.

Each mailcap entry consists of one virtual line, optionally split into multiple physical lines with the ``\'' character present at the very end of all lines but the last. For example:

   text/plain;scoedit -r %s; compose=scoedit %s; edit=scoedit %s
This line may be split into:
   scoedit -r %s; compose=scoedit %s;\
   edit=scoedit %s
Blank lines are ignored and lines that start with the number sign character (#) are considered comments.

Format of an entry

The format of a mailcap entry is as follows:

type/subtype; view-command [; keyword=key-command ... ]

The type, subtype, and view-command fields are mandatory.

The type field indicates the type of data this entry describes how to handle. The subtype field specifies the subtype, if any. If subtype is an asterisk (*), all subtypes of type are described by the entry. The combination of type/subtype is matched against the contents of the Content-Type header of a mail message.

The view-command field indicates how the mail type can be viewed or printed. This field must include a complete Bourne shell command line. One or more instances of the characters %s may be included in the view-command field. These characters are replaced by the name of a file that contains the actual data from the mail message. If the %s characters are not included, the mail data is passed to the view-command as standard input. If the file indicated by %s is expected to be present after the view-command field program exits, the view-command must save the data before exiting (otherwise the file %s may not still exist).

One or more instances of the characters %t may be included. These characters are replaced by the contents of the type/subtype fields.

Instances of %{parameter} are replaced by the value of parameter as taken from the Content-Type header of the mail message. For example, given this Content-Type header:

Content-Type: TEXT/PLAIN; charset=US-ASCII

If the view-command field includes the string %{charset}, that string is replaced with the value US-ASCII.

The characters %n and %F may also be used. If the value of Content-Type is multipart, %n is replaced with an integer that specifies the number of subparts in the multipart message. The %F characters are replaced, when the Content-Type is multipart, with a line including two strings for each subpart: the subpart's Content-Type and a filename indicating a temporary file where the subpart is stored.

The keyword field can include one of the values compose, edit, print, or needsterminal. The key-command following a compose keyword specifies a program that can compose a new message or message part in the named format. The program should produce the new data as its output and the data will be given a Content-Type field as specified in the mailcap entry (the type/subtype being described). Each compose command must contain one or more instances of the characters %s, which are replaced by the name of a file that contains the output of the specified program.

The key-command following an edit keyword specifies a program that can be used to edit a message or message part in the named format.

The key-command following a print keyword specifies a program that can be used to print a message or message part in the named format.

The needsterminal keyword specifies that view-command must be run on an interactive terminal. This indicates that the program should be executed in a scoterm window. The needterminal keyword also applies to the edit and compose keywords.


user-specific mailcap file

default system-wide mailcap file

See also

scomail(XC), scoterm(XC), sh(C)

See also RFC 1524, which was written by Nathaniel S. Borenstein, and RFC 1521 (MIME).

Standards conformance

mailcap is not part of any currently supported standard.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003