Skip to content
Search

Mailcap

lastmod 2026-02-18created 2026-02-181 edits

mailcap is a system that defines which program handles files of each MIME type. It was originally created to specify the programs email clients use to open attachments (RFC 1524), and today various programs consult it when looking up MIME handlers.

Configuration files

File path

Description

/etc/mailcap

System-wide configuration

~/.mailcap

Per-user configuration (takes precedence)

Format

Each line has the form MIME type; command to run, and the file path is substituted for %s.

audio/mpeg; mpv %s
application/pdf; evince %s
image/png; feh %s
text/html; firefox %s

Option fields

In addition to the basic format, extra options can be specified, separated by semicolons (;).

image/gif; feh %s; test=test -n "$DISPLAY"
text/html; lynx %s; needsterminal
application/pdf; evince %s; description="PDF Viewer"

Field

Description

test=

Use the entry only when the condition is true

needsterminal

Marks the program as requiring a terminal

copiousoutput

Produces a large amount of output, so it is displayed through a pager

description=

Description of the entry

compose=

Command used to create a file of that MIME type

edit=

Command used to edit a file of that MIME type

Command

Description

run-mailcap

General-purpose command that opens files according to the mailcap configuration

see

Alias for run-mailcap --action=view

edit

Alias for run-mailcap --action=edit

compose

Alias for run-mailcap --action=compose

mailcap vs xdg-open

Item

mailcap

xdg-open

Configuration method

Text file (/etc/mailcap)

.desktop files + mimeapps.list

Main environment

CLI / headless servers

GUI desktop environments

Standard

RFC 1524

freedesktop.org XDG specification

Pros

Simple and intuitive

Integrated with the desktop environment

See also

Favorite site

author Zer0 sitemap