ELinks Mailcap support

This document describes the support for mailcap (rfc1524) in ELinks. It does not describe the mailcap format. There are plenty of documents on the web that does this. Google and thou shall find. ;)

Index:
1. A short intro to mailcap
2. Parameters
3. Reading of mailcap files
4. Fields
5. Configuration
6. Some sample mailcap entries


1. A short intro to mailcap

Mailcap is a file format defined in rfc 1524. It is purpose is to inform multiple mail reading user agent (MUA) programs about the locally-installed facilities for handling mail in various formats. It is designed to work with the Multipurpose Internet Mail Extensions, known as MIME.

ELinks supports MIME quite well already so why support mailcap ? It can be seen as an alternative or simply as a supplement for setting up mime handler. Mailcap files are present at most UNIX systems (/etc/mailcap) so this makes it possible for ELinks to know how to handle a great variety of file formats with little configuration. To be able to use mailcap it has to be compiled into ELinks. This is the default. If you don't need mailcap support just configure ELinks with the flag: --disable-mailcap.


2. Parameters

The code has been ported from mutt and thereby inherits some of it's various features and limitation.

The following parameters are not supported. Since they do not make much sense for non-MUA:

%n
is the integer number of sub-parts in the multipart
%F
is "content-type filename" repeated for each sub-part
%{parameter}
is replaced by the parameter value from the content-type field

The following parameters are supported:

%s
is the filename that contains the data.
%f
is the content type, like text/plain

3. Reading of mailcap files

Mailcap files will be read when starting ELinks. The mailcap files to use will be found from the a mailcap path a colon seperated list of files similar to $PATH environment variable. The mailcap path will be determined in the following way:


4. Fields

Since mailcap handling is primarily for displaying of resources all fields like edit, print, compose etc. is ignored.

Note: Test commands are supported but unfortunately it's not possible to provide the file when running the test. So any test that requires a file will be considered failed and the handler will not be used.

Unfortunately there are no 'native' support for the copiousoutput field. The field basicly mean 'needs pager'. So it is handled by appending a pipe and a pager program to the command. The pager program will be read from the PAGER environment variable. If this fails test are made for common pager programs (/usr/bin/pager, /usr/bin/less and /usr/bin/more in that order). So if you define png2ascii as your handler for image/png and specify copiousoutput then the executed command will be png2ascii |/usr/bin/less if less is your pager or present on your system.


5. Mailcap configuration

Apart from the protocol.mailcap.path option you can configure if mailcap support should be disabled. The default being that it is enabled. To disable it just put:

        set protocol.mailcap.enable = 0

in elinks.conf.

It is also possible to control wether ELinks should ask you before opening a file. The option is a boolian and can be set like this:

        set protocol.mailcap.ask = 1

if you would like to be asked before opening a file.


6. Some sample mailcap entries

# Use xv if X is running
image/*;                xv %s ; test=test -n "$DISPLAY";

# Convert images to text using the netpbm tools
image/*;                (anytopnm %s | pnmscale -xysize 200 150 | \
				pnminvert | ppmtopgm | pgmtopbm | \
				pbmtoascii -1x2 ) 2>&1 ; copiousoutput

# Various multimedia files
audio/mpeg;             xmms '%s'; test=test -n "$DISPLAY";
application/pdf;        xpdf '%s'; test=test -n "$DISPLAY";
application/postscript; ps2ascii %s ; copiousoutput

$Id: mailcap.html,v 1.3 2002/12/11 13:53:28 jonas Exp $