reformime (1) Linux Manual Page
NAME
reformime – MIME E-mail reformatting tool
SYNOPSIS
-
reformime[options…]
DESCRIPTION
reformime
Generally, reformime expects to see an m[blue]RFC 2045m[][1] compliant message on standard input, except in few cases such as the -m option.
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:
-
1 1.1 1.2
This shows 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. In this case it happens to be a multipart/mixed message. "1.1" refers to the first section of the multipart 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.
If the message is not a MIME message, or it does not contain any attachments, reformime prints only "1", that refers to the entire message itself:
-
1
Here’s the output from reformime when the first part of the message was itself a multipart/alternative section:
-
1 1.1 1.1.1 1.1.2 1.2
Arbitrarily complex MIME constructs are possible.
OPTIONS
-d
- Parse a delivery status notification MIME message (m[blue]
RFC 1894m[][2]).reformimeexpects to see on standard input a MIME message that consists of a delivery status notification, as defined by RFC 1894.reformimereads the message and prints on standard output a list of addresses and their corresponding delivery status, as specified in the delivery status notification. Each line printed byreformimeconsists of a delivery status, a space, and the address.reformimethen terminates with a 0 exit status.reformimeproduces no output and terminates with an exit status of 1 if the standard input does not contain a delivery status notification.
-D
- Like the
-dexcept thatreformimelists the address found in the Original-Recipient: header, if it exists.
-e
- Extract the contents of the indicated MIME section, and display it on standard output. The
-soption is required when-eis specified. If the specified section or sections use either the base64 or quoted-printable encoding method,reformimeautomatically decodes it. In this case you’re better off redirecting the standard output into a file.
-i
- Display MIME information for each section.
reformimedisplays the contents of the Content-Type: header, any encoding used, and the character set.reformimealso displays the byte offset in the message where each section starts and ends (and where the actual contents of the section start, after skipping all the headers).
-m
- Create a multipart/digest MIME message digest.
-r
- Rewrite message, adding or standardizing m[blue]
RFC 2045m[][1] MIME headers.
-r7
- Like
-rbut also convert 8bit-encoded MIME sections to quoted-printable.
-r8
- Like
-rbut also convert quoted-printable-encoded MIME sections to 8bit.
-s section
- Display MIME information for this section only. section is a MIME specification tag. The
-soption is required if-eis also specified, and is optional with-i.Multiple sections may be specified by separating them with commas.
reformimeprocesses each section using the other options that were specified.
-x
- Extract the contents of the indicated MIME section to a file.
-X
- Pipe the contents of the indicated MIME section to a program.
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. If -s lists multiple sections, each section gets extracted separately. quoted-printable and base64 encoding are automatically decoded.
-x
- Interactive extraction.
reformimeprints the MIME content type of each section. Answer with ‘y’ or ‘Y’ to extract the MIME section. Specify the filename at the next prompt.reformimeprompts with a default filename.reformimetries to choose the default filename based on the MIME headers, if possible. If not, the default filename will be attachment1.dat (if the -s option is not specified, the next filename will be attachment2.dat, and so on).
-xPREFIX
- Automatic extraction.
reformimeautomatically extracts one or more MIME sections, and saves them to a file. The filename is formed by taking PREFIX, and appending the default filename to it. Note that there’s no space between "-x" and "PREFIX". For example:-
reformime -xfiles-
This command saves MIME sections as files-attachment1.dat, then files-attachment2.dat, etc.
reformimetries to append the filename specified in the MIME headers for each section, where possible.reformimereplaces all suspect characters with the underscore character.
-X prog arg1 arg2 …
- The
-Xoption must be the last option toreformime.reformimeruns an external programprog, and pipes the contents of the MIME section to the program.reformimesets the environment variableCONTENT_TYPEto the MIME content type. The environment variableFILENAMEgets set to the default filename ofreformime‘s liking. If the-soption is not specified, the program runs once for every MIME section in the message. The external program,progmust terminate with a zero exit status in order forreformimeto proceed to the next MIME section in the message (or the next section specified by-s). In any case, ifprogterminates with a non-zero exit status,reformimeterminates with the exit status of 20 plusprog‘s exit status.
-
Notereformimeextracts every MIME section in the message unless the-soption is specified. This includes even the text/plain MIME content 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 adds one.
If the Content-Transfer-Encoding: header contains 8bit or raw, but only seven-bit data is found, reformime changes the Content-Transfer-Encoding header to 7bit.
-r7 does the same thing, but also converts 8bit-encoded content that contains eight-bit characters to quoted-printable encoding.
-r8 does the same thing, but also converts quoted-printable-encoded content to 8bit, except in some situations.
Creating multipart/digest MIME digests
The -m option creates a MIME digest. reformime reads a list of filenames on standard input. Each line read from standard input contains the name of a file that is presumed to contain an RFC 2822-formatted message. reformime splices all files into a multipart/digest MIME section, and writes it to standard output.
Translating MIME headers
The following options do not read a message from standard input. These options process MIME headers via the command line, and are designed to be conveniently used by mail-handling scripts.
-h "header"
- Decode a MIME-encoded "header" and print the decoded 8-bit content on standard output. The decoding gets carried out as if the contents occurred in the “Subject” header. Example:
-
$ reformime -h '=?iso-8859-1?Q?H=F3la!?=' Hóla!
-H "header"
- Like
-hexcept that header is parsed as a list of email addresses, like “From” or “To”.
-o "text"
- MIME-encode "text", and print the results on standard output.
-O "text"
- Like the
-o option, except that text is a structured header with RFC 2822 addresses.
-c "charset"
- Use charset as the character set setting, by the
-h,-H,-oand-Ooptions.
-u
- This “undocumented” option reads a MIME message on standard input, and converts its contents to an UTF-8-encoded character stream, which is written to standard output.
The standard output receives a concatenated amalgam of the headers and “text” MIME object data. It is meant to be used as part of a generic search function. This option decodes various kinds of header MIME encoding, the quoted-printable and base64 transfer encodings of “text” MIME objects.
SEE ALSO
m[blue]reformail(1)m[][3], sendmail(8), m[blue]mailbot(1)m[][4], m[blue]maildrop(1)m[][5], m[blue]maildropfilter(5)m[][6], egrep(1), grep(1), sendmail(8).
AUTHOR
Sam Varshavchik
- Author
NOTES
- 1.
- RFC 2045
- 2.
- RFC 1894
- 3.
-
reformail(1)- [set $man.base.url.for.relative.links]/reformail.html
- 4.
-
mailbot(1)- [set $man.base.url.for.relative.links]/mailbot.html
- 5.
-
maildrop(1)- [set $man.base.url.for.relative.links]/maildrop.html
- 6.
-
maildropfilter(5)- [set $man.base.url.for.relative.links]/maildropfilter.html
