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
487
488
489
490
491
492
493
494
495
496
|
'\" t
.\"<!-- Copyright 1998 - 2010 Double Precision, Inc. See COPYING for -->
.\"<!-- distribution information. -->
.\" Title: reformime
.\" Author: Sam Varshavchik
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 06/20/2015
.\" Manual: Double Precision, Inc.
.\" Source: Courier Mail Server
.\" Language: English
.\"
.TH "REFORMIME" "1" "06/20/2015" "Courier Mail Server" "Double Precision, Inc\&."
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
reformime \- MIME E\-mail reformatting tool
.SH "SYNOPSIS"
.HP \w'\fBreformime\fR\ 'u
\fBreformime\fR [\fIoptions\fR...]
.SH "DESCRIPTION"
.PP
\fBreformime\fR
is a utility for reformatting MIME messages\&.
.PP
Generally,
\fBreformime\fR
expects to see an
\m[blue]\fBRFC 2045\fR\m[]\&\s-2\u[1]\d\s+2
compliant message on standard input, except in few cases such as the
\fB\-m\fR
option\&.
.PP
If no options are given,
\fBreformime\fR
prints the MIME structure of the message\&. The output consists of so\-called "MIME reference tags", one per line\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
1
1\&.1
1\&.2
.fi
.if n \{\
.RE
.\}
.PP
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\&.
.PP
If the message is not a MIME message, or it does not contain any attachments,
\fBreformime\fR
prints only "1", that refers to the entire message itself:
.sp
.if n \{\
.RS 4
.\}
.nf
1
.fi
.if n \{\
.RE
.\}
.PP
Here\*(Aqs the output from
\fBreformime\fR
when the first part of the message was itself a
multipart/alternative
section:
.sp
.if n \{\
.RS 4
.\}
.nf
1
1\&.1
1\&.1\&.1
1\&.1\&.2
1\&.2
.fi
.if n \{\
.RE
.\}
.PP
Arbitrarily complex MIME constructs are possible\&.
.SH "OPTIONS"
.PP
\-d
.RS 4
Parse a delivery status notification MIME message (\m[blue]\fBRFC 1894\fR\m[]\&\s-2\u[2]\d\s+2)\&.
\fBreformime\fR
expects to see on standard input a MIME message that consists of a delivery status notification, as defined by RFC 1894\&.
\fBreformime\fR
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
\fBreformime\fR
consists of a delivery status, a space, and the address\&.
\fBreformime\fR
then terminates with a 0 exit status\&.
\fBreformime\fR
produces no output and terminates with an exit status of 1 if the standard input does not contain a delivery status notification\&.
.RE
.PP
\-D
.RS 4
Like the
\fB\-d\fR
except that
\fBreformime\fR
lists the address found in the
Original\-Recipient:
header, if it exists\&.
.RE
.PP
\-e
.RS 4
Extract the contents of the indicated MIME section, and display it on standard output\&. The
\fB\-s\fR
option is required when
\fB\-e\fR
is specified\&. If the specified section or sections use either the
base64
or
quoted\-printable
encoding method,
\fBreformime\fR
automatically decodes it\&. In this case you\*(Aqre better off redirecting the standard output into a file\&.
.RE
.PP
\-i
.RS 4
Display MIME information for each section\&.
\fBreformime\fR
displays the contents of the
Content\-Type:
header, any encoding used, and the character set\&.
\fBreformime\fR
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)\&.
.RE
.PP
\-m
.RS 4
Create a
multipart/digest
MIME message digest\&.
.RE
.PP
\-r
.RS 4
Rewrite message, adding or standardizing
\m[blue]\fBRFC 2045\fR\m[]\&\s-2\u[1]\d\s+2
MIME headers\&.
.RE
.PP
\-r7
.RS 4
Like
\fB\-r\fR
but also convert
8bit\-encoded MIME sections to
quoted\-printable\&.
.RE
.PP
\-r8
.RS 4
Like
\fB\-r\fR
but also convert
quoted\-printable\-encoded MIME sections to
8bit\&.
.RE
.PP
\-s \fIsection\fR
.RS 4
Display MIME information for this section only\&.
\fIsection\fR
is a MIME specification tag\&. The
\fB\-s\fR
option is required if
\fB\-e\fR
is also specified, and is optional with
\fB\-i\fR\&.
.sp
Multiple sections may be specified by separating them with commas\&.
\fBreformime\fR
processes each section using the other options that were specified\&.
.RE
.PP
\-x
.RS 4
Extract the contents of the indicated MIME section to a file\&.
.RE
.PP
\-X
.RS 4
Pipe the contents of the indicated MIME section to a program\&.
.RE
.SS "Extracting RFC 2045 MIME section(s) to file(s)"
.PP
The
\fB\-x\fR
and
\fB\-X\fR
options extract a specific MIME section to a file or to a pipe to an external program\&. Use the
\fB\-s\fR
option to identify the MIME section to extract\&. If the
\fB\-s\fR
option is not specified, every MIME section in the message is extracted, one at a time\&. If
\fB\-s\fR
lists multiple sections, each section gets extracted separately\&.
quoted\-printable
and
base64
encoding are automatically decoded\&.
.PP
\-x
.RS 4
Interactive extraction\&.
\fBreformime\fR
prints the MIME content type of each section\&. Answer with \*(Aqy\*(Aq or \*(AqY\*(Aq to extract the MIME section\&. Specify the filename at the next prompt\&.
\fBreformime\fR
prompts with a default filename\&.
\fBreformime\fR
tries 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)\&.
.RE
.PP
\-x\fIPREFIX\fR
.RS 4
Automatic extraction\&.
\fBreformime\fR
automatically extracts one or more MIME sections, and saves them to a file\&. The filename is formed by taking
\fIPREFIX\fR, and appending the default filename to it\&. Note that there\*(Aqs no space between "\-x" and "PREFIX"\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
reformime \-xfiles\-
.fi
.if n \{\
.RE
.\}
This command saves MIME sections as
files\-attachment1\&.dat, then
files\-attachment2\&.dat, etc\&.
\fBreformime\fR
tries to append the filename specified in the MIME headers for each section, where possible\&.
\fBreformime\fR
replaces all suspect characters with the underscore character\&.
.RE
.PP
\-X prog arg1 arg2 \&.\&.\&.
.RS 4
The
\fB\-X\fR
option must be the last option to
\fBreformime\fR\&.
\fBreformime\fR
runs an external program
\fBprog\fR, and pipes the contents of the MIME section to the program\&.
\fBreformime\fR
sets the environment variable
\fBCONTENT_TYPE\fR
to the MIME content type\&. The environment variable
\fBFILENAME\fR
gets set to the default filename of
\fBreformime\fR\*(Aqs liking\&. If the
\fB\-s\fR
option is not specified, the program runs once for every MIME section in the message\&. The external program,
\fBprog\fR
must terminate with a zero exit status in order for
\fBreformime\fR
to proceed to the next MIME section in the message (or the next section specified by
\fB\-s\fR)\&. In any case, if
\fBprog\fR
terminates with a non\-zero exit status,
\fBreformime\fR
terminates with the exit status of 20 plus
\fBprog\fR\*(Aqs exit status\&.
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
\fBreformime\fR
extracts every MIME section in the message unless the
\fB\-s\fR
option is specified\&. This includes even the
text/plain
MIME content that usually precedes a binary attachment\&.
.sp .5v
.RE
.SS "Adding RFC 2045 MIME headers"
.PP
The
\fB\-r\fR
option performs the following actions:
.PP
If there is no
Mime\-Version:,
Content\-Type:, or
Content\-Transfer\-Encoding:
header,
\fBreformime\fR
adds one\&.
.PP
If the
Content\-Transfer\-Encoding:
header contains
8bit
or
raw, but only seven\-bit data is found,
\fBreformime\fR
changes the
Content\-Transfer\-Encoding
header to
7bit\&.
.PP
\fB\-r7\fR
does the same thing, but also converts
8bit\-encoded content that contains eight\-bit characters to
quoted\-printable
encoding\&.
.PP
\fB\-r8\fR
does the same thing, but also converts
quoted\-printable\-encoded content to
8bit, except in some situations\&.
.SS "Creating multipart/digest MIME digests"
.PP
The
\fB\-m\fR
option creates a MIME digest\&.
\fBreformime\fR
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\&.
\fBreformime\fR
splices all files into a
\fBmultipart/digest\fR
MIME section, and writes it to standard output\&.
.SS "Translating MIME headers"
.PP
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\&.
.PP
\-h "\fIheader\fR"
.RS 4
Decode a MIME\-encoded "\fIheader\fR" and print the decoded 8\-bit content on standard output\&. The decoding gets carried out as if the contents occurred in the
\(lqSubject\(rq
header\&. Example:
.sp
.if n \{\
.RS 4
.\}
.nf
$ reformime \-h \*(Aq=?iso\-8859\-1?Q?H=F3la!?=\*(Aq
Hóla!
.fi
.if n \{\
.RE
.\}
.RE
.PP
\-H "\fIheader\fR"
.RS 4
Like
\fB\-h\fR
except that
\fIheader\fR
is parsed as a list of email addresses, like
\(lqFrom\(rq
or
\(lqTo\(rq\&.
.RE
.PP
\-o "\fItext\fR"
.RS 4
MIME\-encode "\fItext\fR", and print the results on standard output\&.
.RE
.PP
\-O "\fItext\fR"
.RS 4
Like the
\fB\-o option\fR, except that
\fItext\fR
is a structured header with RFC 2822 addresses\&.
.RE
.PP
\-c "\fIcharset\fR"
.RS 4
Use
\fIcharset\fR
as the character set setting, by the
\fB\-h\fR,
\fB\-H\fR,
\fB\-o\fR
and
\fB\-O\fR
options\&.
.RE
.PP
\-u
.RS 4
This
\(lqundocumented\(rq
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\&.
.sp
The standard output receives a concatenated amalgam of the headers and
\(lqtext\(rq
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
\(lqtext\(rq
MIME objects\&.
.RE
.SH "SEE ALSO"
.PP
\m[blue]\fB\fBreformail\fR(1)\fR\m[]\&\s-2\u[3]\d\s+2,
\fBsendmail\fR(8),
\m[blue]\fB\fBmailbot\fR(1)\fR\m[]\&\s-2\u[4]\d\s+2,
\m[blue]\fB\fBmaildrop\fR(1)\fR\m[]\&\s-2\u[5]\d\s+2,
\m[blue]\fB\fBmaildropfilter\fR(5)\fR\m[]\&\s-2\u[6]\d\s+2,
\fBegrep\fR(1),
\fBgrep\fR(1),
\fBsendmail\fR(8)\&.
.SH "AUTHOR"
.PP
\fBSam Varshavchik\fR
.RS 4
Author
.RE
.SH "NOTES"
.IP " 1." 4
RFC 2045
.RS 4
\%http://www.rfc-editor.org/rfc/rfc2045.txt
.RE
.IP " 2." 4
RFC 1894
.RS 4
\%http://www.rfc-editor.org/rfc/rfc1894.txt
.RE
.IP " 3." 4
\fBreformail\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/reformail.html
.RE
.IP " 4." 4
\fBmailbot\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/mailbot.html
.RE
.IP " 5." 4
\fBmaildrop\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/maildrop.html
.RE
.IP " 6." 4
\fBmaildropfilter\fR(5)
.RS 4
\%[set $man.base.url.for.relative.links]/maildropfilter.html
.RE
|