The Mutt E-Mail Client : Mutt's MIME Support : MIME Viewer configuration with `mailcap` : The Basics of the mailcap file
Previous: MIME Viewer configuration with `mailcap`
Next: Secure use of mailcap

## 5.3.1. The Basics of the mailcap file

A mailcap file consists of a series of lines which are comments, blank, or definitions.

A comment line consists of a # character followed by anything you want.

A blank line is blank.

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 ';' character.

The content type is specified in the MIME standard type/subtype method. For example, `text/plain, text/html, image/gif,` etc. In addition, the mailcap format includes two formats for wildcards, one using the special '*' subtype, the other is the implicit wild, where you only include the major type. For example, `image/*`, or `video,` will match all image types and video types, respectively.

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 behaviour by using %s 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 %s 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.

So, in the simplest form, you can send a text/plain message to the external pager more on stdin:

> `

>     text/plain; more

> `

Or, you could send the message as a file:

> `

>     text/plain; more %s

> `

Perhaps you would like to use lynx to interactively view a text/html message:

> `

>     text/html; lynx %s

> `

In this case, lynx does not support viewing a file from stdin, so you must use the %s syntax. Note: Some older versions of lynx contain a bug where they will check the mailcap file for a viewer for text/html. They will find the line which calls lynx, and run it. This causes lynx to continuously spawn itself to view the object.

On the other hand, maybe you don't want to use lynx interactively, you just want to have it convert the text/html to text/plain, then you can use:

> `

>     text/html; lynx -dump %s | more

> `

Perhaps you wish to use lynx to view text/html files, and a pager on all other text formats, then you would use the following:

> `

>     text/html; lynx %s
>     text/*; more

> `

This is the simplest form of a mailcap file.

The Mutt E-Mail Client : Mutt's MIME Support : MIME Viewer configuration with `mailcap` : The Basics of the mailcap file
Previous: MIME Viewer configuration with `mailcap`
Next: Secure use of mailcap