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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
<!-- Copyright 1998 - 2010 Double Precision, Inc. See COPYING for -->
<!-- distribution information. -->
<refentry id="reformime">
<info><author><firstname>Sam</firstname><surname>Varshavchik</surname><contrib>Author</contrib></author><productname>Courier Mail Server</productname></info>
<refmeta>
<refentrytitle>reformime</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class='manual'>Double Precision, Inc.</refmiscinfo>
</refmeta>
<refnamediv>
<refname>reformime</refname>
<refpurpose>MIME E-mail reformatting tool</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis sepchar=" ">
<command>reformime</command>
<arg rep="repeat" choice="opt"><replaceable>options</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id="reformime_description">
<title>DESCRIPTION</title>
<para>
<command>reformime</command> is a utility for reformatting
MIME messages.</para>
<para>
Generally, <command>reformime</command> expects to see an
<ulink url="http://www.rfc-editor.org/rfc/rfc2045.txt">RFC 2045</ulink>
compliant message on standard input, except in few cases
such as the <option>-m</option> option.</para>
<para>
If no options are given, <command>reformime</command> prints the MIME
structure of the message. The output consists of so-called
"MIME reference tags", one per line.
For example:</para>
<blockquote>
<informalexample>
<programlisting format="linespecific">
1
1.1
1.2
</programlisting>
</informalexample>
</blockquote>
<para>
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 <literal>multipart/mixed</literal>
message. "1.1" refers to the first section of the multipart message, which
happens to be a
<literal>text/plain</literal> section. "1.2" refers to the second
section of the message, which happens to be an
<literal>application/octet-stream</literal> section.</para>
<para>
If the message is not a MIME message, or it does not contain any
attachments, <command>reformime</command> prints only "1", that refers
to the entire message itself:</para>
<blockquote>
<informalexample>
<programlisting format="linespecific">
1
</programlisting>
</informalexample>
</blockquote>
<para>
Here's the output from
<command>reformime</command> when the first part of the message was itself a
<literal>multipart/alternative</literal> section:</para>
<blockquote>
<informalexample>
<programlisting format="linespecific">
1
1.1
1.1.1
1.1.2
1.2
</programlisting>
</informalexample>
</blockquote>
<para>
Arbitrarily complex MIME constructs are possible.</para>
</refsect1>
<refsect1 id="reformime_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>-d</term>
<listitem>
<para>
Parse a delivery status notification MIME message
(<ulink url="http://www.rfc-editor.org/rfc/rfc1894.txt">RFC 1894</ulink>).
<command>reformime</command>
expects to see on standard input a MIME message that consists of
a delivery status notification, as defined by RFC 1894.
<command>reformime</command>
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
<command>reformime</command>
consists of a delivery
status, a space, and the address.
<command>reformime</command> then terminates with a 0 exit status.
<command>reformime</command> produces no output and terminates with an exit
status of 1 if the standard input does not contain a delivery status
notification.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-D</term>
<listitem>
<para>
Like the <option>-d</option> except that
<command>reformime</command> lists the address
found in the <literal>Original-Recipient:</literal> header,
if it exists.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-e</term>
<listitem>
<para>
Extract the contents of the indicated MIME section, and display it
on standard output.
The <option>-s</option> option is required when
<option>-e</option> is specified. If the
specified section or
sections use either the <literal>base64</literal> or
<literal>quoted-printable</literal> encoding method,
<command>reformime</command> automatically
decodes it. In this case you're better off redirecting the standard output
into a file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-i</term>
<listitem>
<para>
Display MIME information for each section. <command>reformime</command>
displays the contents of the
<literal>Content-Type:</literal> header, any encoding used,
and the character set.
<command>reformime</command> also 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).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-m</term>
<listitem>
<para>
Create a <literal>multipart/digest</literal> MIME message digest.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-r</term>
<listitem>
<para>
Rewrite message, adding or standardizing
<ulink url="http://www.rfc-editor.org/rfc/rfc2045.txt">RFC 2045</ulink>
MIME headers.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-r7</term>
<listitem>
<para>
Like <option>-r</option> but also convert <literal>8bit</literal>-encoded
MIME sections to <literal>quoted-printable</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-r8</term>
<listitem>
<para>
Like <option>-r</option> but also convert
<literal>quoted-printable</literal>-encoded MIME sections to
<literal>8bit</literal>, except in some situations, see below.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-rU</term>
<listitem>
<para>
Unconditionally convert
<literal>quoted-printable</literal>-encoded MIME sections to
<literal>8bit</literal>, even when the resulting message may not
necessarily comply
with Internet message formatting standards.
See below for more information.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-s <replaceable>section</replaceable></term>
<listitem>
<para>
Display MIME information for this section only.
<replaceable>section</replaceable> is
a MIME specification tag. The <option>-s</option> option is required if
<option>-e</option> is also
specified, and is optional with <option>-i</option>.</para>
<para>
Multiple sections may be specified by separating them with commas.
<command>reformime</command> processes each section using the other options
that were specified.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-x</term>
<listitem>
<para>
Extract the contents of the indicated MIME section to a file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-X</term>
<listitem>
<para>
Pipe the contents of the indicated MIME section to a program.</para>
</listitem>
</varlistentry>
</variablelist>
<refsect2 id="reformime_extracting_rfc_2045_mime_section_s__to_file_s_">
<title>Extracting RFC 2045 MIME section(s) to file(s)</title>
<para>
The <option>-x</option> and <option>-X</option> options extract a specific
MIME section to a file or to a pipe to an external program.
Use the <option>-s</option> option to identify the MIME section
to extract. If the <option>-s</option> option is not specified,
every MIME section in the message is extracted, one at a time.
If <option>-s</option> lists multiple sections, each section gets
extracted separately.
<literal>quoted-printable</literal> and <literal>base64</literal> encoding are
automatically decoded.</para>
<variablelist>
<varlistentry>
<term>-x</term>
<listitem>
<para>
Interactive extraction. <command>reformime</command> 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. <command>reformime</command>
prompts with a default filename.
<command>reformime</command> tries to choose the default
filename based on the MIME headers, if possible. If not, the default
filename will be <literal>attachment1.dat</literal> (if the -s option is not
specified, the next filename will be <literal>attachment2.dat</literal>,
and so on).</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-x<replaceable>PREFIX</replaceable></term>
<listitem>
<para>
Automatic extraction. <command>reformime</command> automatically
extracts one or more MIME sections, and saves them to a file.
The filename is formed by taking
<replaceable>PREFIX</replaceable>, and appending the default filename to it.
Note that there's no space between "-x" and "PREFIX". For example:</para>
<blockquote>
<informalexample>
<programlisting format="linespecific">
reformime -xfiles-
</programlisting>
</informalexample>
</blockquote>
<para>
This command saves MIME sections as
<filename>files-attachment1.dat</filename>, then
<filename>files-attachment2.dat</filename>, etc.
<command>reformime</command> tries to append the filename specified in the
MIME headers for each section, where possible.
<command>reformime</command> replaces all suspect characters with the
underscore character.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-X prog arg1 arg2 ...</term>
<listitem>
<para>
The <option>-X</option> option must be the last option to
<command>reformime</command>. <command>reformime</command> runs an external
program <command>prog</command>, and pipes the contents of the MIME section to
the program. <command>reformime</command> sets the environment variable
<envar>CONTENT_TYPE</envar> to the MIME content type. The environment
variable <envar>FILENAME</envar> gets set to the default filename of
<command>reformime</command>'s liking. If the <option>-s</option> option is
not specified, the program runs once
for every MIME section in the message.
The external program, <command>prog</command> must terminate with a zero
exit status in order for <command>reformime</command> to proceed to the
next MIME section in the message (or the next section specified by
<option>-s</option>).
In any case, if <command>prog</command> terminates with a non-zero exit
status, <command>reformime</command> terminates with the exit status of
20 plus <command>prog</command>'s exit status.</para>
</listitem>
</varlistentry>
</variablelist>
<note>
<para>
<command>reformime</command> extracts every MIME section in the message
unless the <option>-s</option> option is specified.
This includes even the <literal>text/plain</literal> MIME
content that usually precedes a binary attachment.</para>
</note>
</refsect2>
<refsect2 id="reformime_adding_rfc_2045_mime_headers">
<title>Adding RFC 2045 MIME headers</title>
<para>
The <option>-r</option> option performs the following actions:</para>
<para>
If there is no <literal>Mime-Version:</literal>,
<literal>Content-Type:</literal>, or
<literal>Content-Transfer-Encoding:</literal> header,
<command>reformime</command> adds one.</para>
<para>
If the <literal>Content-Transfer-Encoding:</literal> header contains
<literal>8bit</literal> or <literal>raw</literal>, but only seven-bit data is
found, <command>reformime</command> changes
the <literal>Content-Transfer-Encoding</literal> header to
<literal>7bit</literal>.</para>
<para><option>-r7</option> does the same thing, but also converts
<literal>8bit</literal>-encoded content that contains eight-bit characters to
<literal>quoted-printable</literal> encoding.</para>
<para><option>-r8</option> does the same thing, but also converts
<literal>quoted-printable</literal>-encoded content to
<literal>8bit</literal>, except in some situations. The content remains
<literal>quoted-printable</literal> if converting it results in excessively
long lines of text.
</para>
<para><option>-rU</option> always converts
<literal>quoted-printable</literal>-encoded content to
<literal>8bit</literal> potentially resulting in excessively
long lines of text. The resulting message should not be resubmitted for
mail delivery, as a delivery failure may occur.
</para>
</refsect2>
<refsect2 id="reformime_creating_multipart_digest_mime_digests">
<title>Creating <literal>multipart/digest</literal> MIME digests</title>
<para>The <option>-m</option> option creates a MIME digest.
<command>reformime</command> 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.
<command>reformime</command> splices all files into a
<command>multipart/digest</command> MIME section,
and writes it to standard output.</para>
</refsect2>
<refsect2 id="reformime_translating_mime_headers">
<title>Translating MIME headers</title>
<para>
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.</para>
<variablelist>
<varlistentry>
<term>-h "<replaceable>header</replaceable>"</term>
<listitem>
<para>
Decode a MIME-encoded "<replaceable>header</replaceable>" and print the
decoded 8-bit content on standard output.
The decoding gets carried out as if the contents occurred in the
<quote>Subject</quote> header.
Example:</para>
<informalexample>
<programlisting format="linespecific">
$ reformime -h '=?iso-8859-1?Q?H=F3la!?='
Hóla!
</programlisting>
</informalexample>
</listitem>
</varlistentry>
<varlistentry>
<term>-H "<replaceable>header</replaceable>"</term>
<listitem>
<para>
Like <option>-h</option> except that <replaceable>header</replaceable> is
parsed as a list of
email addresses, like <quote>From</quote> or <quote>To</quote>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-o "<replaceable>text</replaceable>"</term>
<listitem>
<para>
MIME-encode "<replaceable>text</replaceable>", and print the results
on standard output.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-O "<replaceable>text</replaceable>"</term>
<listitem>
<para>
Like the <option>-o option</option>, except that
<replaceable>text</replaceable>
is a structured header with RFC 2822 addresses.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-c "<replaceable>charset</replaceable>"</term>
<listitem>
<para>
Use <replaceable>charset</replaceable> as the character set
setting, by the
<option>-h</option>,
<option>-H</option>,
<option>-o</option> and
<option>-O</option> options.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-u</term>
<listitem>
<para>
This <quote>undocumented</quote> 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.
</para>
<para>
The standard output receives a concatenated amalgam of the
headers and <quote>text</quote> 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
<literal>quoted-printable</literal> and <literal>base64</literal>
transfer encodings of <quote>text</quote> MIME objects.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<refsect1 id="reformime_see_also">
<title>SEE ALSO</title>
<para>
<ulink url="reformail.html"><citerefentry><refentrytitle>reformail</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>,
<citerefentry><refentrytitle>sendmail</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
<ulink url="mailbot.html"><citerefentry><refentrytitle>mailbot</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>,
<ulink url="maildrop.html"><citerefentry><refentrytitle>maildrop</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>,
<ulink url="maildropfilter.html"><citerefentry><refentrytitle>maildropfilter</refentrytitle><manvolnum>5</manvolnum></citerefentry></ulink>,
<citerefentry><refentrytitle>egrep</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>grep</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sendmail</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
</refsect1>
</refentry>
|