summaryrefslogtreecommitdiffstats
path: root/maildrop/reformime.html
blob: fd1aea4b65ff68e28a91f3bba6b4e41ab10d4fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>reformime - experimental MIME utility</title>
  <!-- Copyright 1998 - 2001 Double Precision, Inc.  See COPYING for -->
  <!-- distribution information. -->
  <!-- SECTION 1 -->
  <meta name="MSSmartTagsPreventParsing" content="TRUE">
</head>

<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B"
alink="#FF0000">
<h1>reformime - reformat/parse MIME messages</h1>

<h2>SYNOPSIS</h2>
<code>reformime [options] ...</code>

<h2>DESCRIPTION</h2>
<i>reformime</i> is a utility for parsing MIME messages.

<p><i>reformime</i> expects to see an RFC 2045 compliant message on standard
input.</p>

<p>If no options are given, <i>reformime</i> 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:</p>
<pre>�
��� 1
��� 1.1
��� 1.2</pre>
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 <code>multipart/mixed</code>
message. "1.1" refers to the first section of the multiparty message, which
happens to be a <code>text/plain</code> section. "1.2" refers to the second
section of the message, which happens to be an
<code>application/octet-stream</code> section. This is a typical situation.

<p>If the message is not a MIME message, or it does not contain any
attachments, you will see a rather boring</p>
<pre>�
��� 1</pre>
If, instead the first part of the message was itself a
<code>multipart/alternative</code> section, you might see the following
instead:
<pre>�
��� 1
��� 1.1
��� 1.1.1
��� 1.1.2
��� 1.2</pre>

<p>Arbitrarily complex MIME constructs are possible.</p>

<h2>OPTIONS</h2>
<ul>
  <li>-d - parse a delivery status notification MIME message (RFC 1894).
    reformime expects to see on standard input a MIME message that consists of
    a delivery status notification, as defined by RFC 1894. reformime reads
    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 by reformime consists of a delivery
    status, a space, and the address reformime will terminate with a 0 exit
    status. reformime produces no output and terminates with an exit status of
    1 if the standard input does not contain a delivery status
    notification.<br>
    <br>
  </li>
  <li>-e - extract the contents of the indicated MIME section, and display it
    on standard output. The -s option is required when -e is specified. If the
    indicated section uses either the <code>base64</code> or
    <code>quoted-printable</code> encoding method, reformime automatically
    decodes it. In this case you're better off redirecting the standard output
    into a file.<br>
    <br>
  </li>
  <li>-x - extract the contents of the indicated MIME section to a file.<br>
    <br>
  </li>
  <li>-X - pipe the contents of the indicated MIME section to a program.<br>
    <br>
  </li>
  <li>-i - display MIME information for each section. <code>reformime</code>
    will display the contents of the Content-Type: header, any encoding used,
    and the character set. <code>reformime</code> will also display at which
    byte offset in the message each section starts and ends (and where the
    actual contents of the section start, skipping all the headers).<br>
    <br>
  </li>
  <li>-s section - display MIME information for this section only. section is
    a MIME specification tag. The -s option is required if -e is also
    specified, and is optional with -i.<br>
    <br>
  </li>
  <li>-r - rewrite message, adding or standardizing RFC 2045 MIME headers.<br>
    <br>
  </li>
  <li>-r7 - also convert MIME sections with 8bit encoding to quoted-printable
    encoding.<br>
    <br>
  </li>
  <li>-r8 - also convert MIME sections with quoted-printable encoding to 8bit
    encoding, where possible.</li>
</ul>

<h3>Extracting RFC 2045 MIME section(s) to file(s)</h3>

<p>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.</p>
<ul>
  <li>-x - interactive extraction. <code>reformime</code> prints the MIME
    content type of each section.  Answer with 'y' or 'Y' to extract the MIME
    section. Specify the filename at the next prompt. <code>reformime</code>
    will prompt with a default filename. reformime tries to choose the default
    filename based on the MIME headers, if possible. If not, the default
    filename will be <code>attachment1.dat</code> (if the -s option is not
    specified, the next filename will be <code>attachment2.dat</code>, and so
    on).<br>
    <br>
  </li>
  <li>-xPREFIX - automatic extraction. <i>reformime</i> will automatically
    extract one or more MIME sections, and save them to a file. The filename
    will be formed by taking PREFIX, and appending the default filename to it.
    Note that there may not be a space between "-x" and "PREFIX". For example:
    "reformime -xfiles-" - this will save MIME sections as
    <code>files-attachment1.dat</code>, then
    <code>files-attachment2.dat</code>, etc. <code>reformime</code> will try
    to append the filename specified in the MIME headers for each section.
    <i>reformime</i> will replace all suspect characters with the underbar,
    when using the filename specified in the MIME headers.<br>
    <br>
  </li>
  <li>-X prog arg1 arg2 ... - the -X option must be the last option to
    <code>reformime</code>. <code>reformime</code> will run an external
    program specified by "prog", and pipe the contents of the MIME section to
    the program. reformime will set the environment variable
    <code>CONTENT_TYPE</code> to the MIME content type.  The environmetn
    variable <code>FILENAME</code> will be set to the default filename of
    reformime's liking. If the -s option is not specified, the program will be
    executed one time for every MIME section in the message.</li>
</ul>

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

<h3>Adding RFC 2045 MIME headers</h3>

<p>The <i>-r</i> option performs the following actions:</p>

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

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

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

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

<h2>BUGS</h2>

<p>-x and -X ignore the Content-Disposition: header.</p>

<h2>FILES</h2>

<p><code>$HOME/.tmp</code> - directory for temporary files. Automatically
created, if necessary.</p>

<h2>SEE ALSO</h2>
<a href="maildrop.html">maildrop(1),</a> <a
href="mailbot.html">mailbot(1),</a> <a
href="maildropfilter.html">maildropfilter(1),</a> <a
href="reformail.html">reformail(1),</a> egrep(1), grep(1), sendmail(8)</body>
</html>