reformime - MIME utility


reformime [options] ...


reformime is a tool for manipulating MIME messages and attachments.

reformime expects to see an RFC 2045, message on standard input.

If no options are given, reformime prints the MIME structure of the message. The output consists of so-called "MIME reference tags", one per line. For example, you might see the following output:

This tells you that the message contains two different MIME sections. The first line of the MIME structure output will always contain "1", which refers to the entire message, which happens to be a multipart/mixed message. "1.1" refers to the first section of the multiparty message, which happens to be a text/plain section. "1.2" refers to the second section of the message, which happens to be an application/octet-stream section. This is a typical situation.

If the message is not a MIME message, or it does not contain any attachments, you will see a rather boring

If, instead the first part of the message was itself a multipart/alternative section, you might see the following instead:

Arbitrarily complex MIME constructs are possible.


Extracting RFC 2045 MIME section(s) to file(s)

The -x and -X options extract a specific MIME section to a file or to a pipe to an external program. Use the -s option to identify the MIME section to extract. If the -s option is not specified, every MIME section in the message is extracted, one at a time. quoted-printable and base64 encoding are automatically decoded.

NOTE: reformime will extract every MIME section in the message unless the -s option is specified. Yes, even the text/plain MIME part that usually precedes a binary attachment.

Adding RFC 2045 MIME headers

The -r option performs the following actions:

If there is no Mime-Version:, Content-Type:, or Content-Transfer-Encoding: header, reformime will add one.

If the Content-Transfer-Encoding: header contains 8bit or raw, but only seven-bit data is found, the Content-Transfer-Encoding header is changed to 7bit.

-r7 does the same thing, but also converts 8bit transfer encoding containing eight-bit characters to quoted-printable encoding.

-r8 does the same thing, but also converts quoted-printable encoded sections to 8bit, except in some situations.

Creating MIME message digests

The -m option is followed by a list of files. Each file should contain a single RFC 822 message. reformime prints, on standard output, a MIME digest containing the indicated messages.

If -m is not followed by at least one file, reformime reads standard input. Each line on standard input must contain a single filename; blank lines are not allowed.


-x and -X ignores the Content-Disposition: header.


$HOME/.tmp - directory for temporary files. Automatically created, if necessary.


maildrop(1), maildropfilter(1), makemime(1), reformail(1), egrep(1), grep(1), courier(8), sendmail(8), RFC 1894, RFC 2045.