Mailcap File Format

A mailcap file is a textual configuration file. It contains entries that associate MIME Content-types with various programs to view, compose, or edit that Content-type. An entry may also contain other supporting information about the programs or the Content-type that is necessary to properly handle the data.

Mailcap entries may be single line or multiline. Multiline entries may be made by ending intermediate lines with a backslash (\) character. Blank lines and lines beginning with a hash (#) character are ignored when parsing mailcap files. Any characters on a line beginning with a hash character are considered to be comments.

Each entry in the file begins with a MIME Content-type (MIME type and subtype), followed by a number of fields. Some fields are name-value pairs, and others are single words. Fields are separated by semicolons (;). Possible fields are described here, but note that specific applications can define their own fields by using the common “X-” syntax as described in Chapter 2, Simple Text Messages.

The second field after the Content-type lists the program to run in order to view data of that type. It is known as the view field and is the only other mandatory field. If an entry for a given Content-type exists, it must have at least a view field defined.

The syntax to call a program is naturally dependent on the underlying operating system; we’ll look at some operating system specifics later in this chapter.

A view field should consist only of a program ...

Get Programming Internet Email now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.