]> diplodocus.org Git - nmh/blob - man/mhfixmsg.man
Add missing -infile switch name to mhfixmsg-format-text/calendar
[nmh] / man / mhfixmsg.man
1 .TH MHFIXMSG %manext1% "February 8, 2015" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
5 .SH NAME
6 mhfixmsg \- rewrite MIME messages with various transformations
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B mhfixmsg
11 .RI [ +folder ]
12 .RI [ msgs " | "
13 .IR "absolute pathname" " | "
14 .RB \-file
15 .IR file ]
16 .RB [ \-decodetext
17 8bit/7bit |
18 .BR \-nodecodetext ]
19 .RB [ \-textcharset
20 .I charset
21 .RB "| " \-notextcharset ]
22 .RB [ \-reformat " | " \-noreformat ]
23 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
24 .RB [ \-fixboundary " | " \-nofixboundary ]
25 .RB [ \-fixcte " | " \-nofixcte ]
26 .RB [ \-fixtype
27 .IR mimetype ]
28 .RB [ \-outfile
29 .IR outfile ]
30 .RB [ \-rmmproc
31 .IR program ]
32 .RB [ \-normmproc ]
33 .RB [ \-changecur " | " \-nochangecur ]
34 .RB [ \-verbose " | " \-noverbose ]
35 .RB [ \-version ]
36 .RB [ \-help ]
37 .ad
38 .SH DESCRIPTION
39 .B mhfixmsg
40 rewrites MIME messages, applying specific transformations such as
41 decoding of MIME-encoded message parts and repairing invalid MIME
42 headers.
43 .PP
44 MIME messages are specified in RFC 2045 to RFC 2049
45 (see
46 .IR mhbuild (1)).
47 The
48 .B mhlist
49 command is invaluable for viewing the content structure of MIME
50 messages.
51 .B mhfixmsg
52 passes non-MIME messages through without any transformations. If no
53 transformations apply to a MIME message, the original message or file
54 is not modified or removed.
55 .PP
56 The
57 .B \-decodetext
58 switch enables a transformation to decode each base64 and
59 quoted-printable text message part to the selected 8bit or 7bit
60 encoding. If 7bit is selected for a base64 part but it will only fit
61 8bit, as defined by RFC 2045, then it will be decoded to 8bit
62 quoted-printable. Otherwise, if the decoded text would not fit the
63 selected encoding, the part is not decoded (and a message will be
64 displayed if
65 .B \-verbose
66 is enabled).
67 .PP
68 When the
69 .B \-decodetext
70 switch is enabled, each carriage return character that precedes a
71 linefeed character is removed from text parts encoded in ASCII,
72 ISO-8859-x, UTF-8, or Windows-12xx.
73 .PP
74 The
75 .B \-textcharset
76 switch specifies that all text/plain parts of the message(s)
77 should be converted to
78 .IR charset .
79 Charset conversions require that
80 .B nmh
81 be built with
82 .IR iconv (3);
83 see the
84 .BR mhparam (1)
85 man page for how determine whether your
86 .B nmh
87 installation includes that.
88 To convert text parts other than text/plain, an external program can
89 be used, via the
90 .B \-reformat
91 switch.
92 .PP
93 The
94 .B \-reformat
95 switch enables a transformation for text parts in the message. For
96 each text part that is not text/plain and that does not have a
97 corresponding text/plain in a multipart/alternative part,
98 .B mhfixmsg
99 looks for a mhfixmsg-format-text/subtype profile entry that matches
100 the subtype of the part. If one is found and can be used to
101 successfully convert the part to text/plain,
102 .B mhfixmsg
103 inserts that text/plain part at the beginning of the containing
104 multipart/alternative part, if present. If not, it creates a
105 multipart/alternative part.
106 .PP
107 With the
108 .B \-reformat
109 switch, multipart/related parts are handled differently than
110 multipart/alternative. If the multipart/related has only a single
111 part that is not text/plain and can be converted to text/plain, a
112 text/plain part is added and the type of the part is changed to
113 multipart/alternative. If the multipart/related has more than one
114 part but does not have a text/plain part,
115 .B mhfixmsg
116 tries to add one.
117 .PP
118 The
119 .B \-replacetextplain
120 switch broadens the applicability of
121 .B \-reformat
122 by always replacing a corresponding text/plain part, if one exists.
123 If
124 .B \-verbose
125 if enabled, the replacement will be shown as two steps: a removal of
126 the text/plain part followed by the usual insertion of a new part.
127 .PP
128 .B \-reformat
129 requires a profile entry for each text part subtype to be reformatted.
130 The mhfixmsg-format-text/subtype profile entries are based on external
131 conversion programs, and are used the same way that
132 .B mhshow
133 uses its mhshow-show-text/subtype entries. When
134 .B nmh
135 is installed, it searches for a conversion program for text/html
136 content, and if one is found, inserts a mhfixmsg-format-text/html
137 entry in %nmhetcdir%/mhn.defaults. An entry of the same name in the
138 user's profile takes precedence. The user can add entries for
139 other text subtypes to their profile.
140 .PP
141 The
142 .B \-fixboundary
143 switch enables a transformation to repair the boundary portion of the
144 Content-Type header field of the message to match the boundaries of
145 the outermost multipart part of the message, if it does not. That
146 condition is indicated by a \*(lqbogus multipart content in
147 message\*(rq error message from
148 .B mhlist
149 and other
150 .B nmh
151 programs that parse MIME messages.
152 .PP
153 The
154 .B \-fixcte
155 switch enables a transformation to change the
156 Content-Transfer-Encoding from an invalid value to 8bit in message
157 parts with a Content-Type of multipart, as required by RFC 2045,
158 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
159 7bit, 8bit, or binary\*(rq error message from
160 .B mhlist
161 and other
162 .B nmh
163 programs that parse MIME messages.
164 .PP
165 The
166 .B \-fixtype
167 switch ensures that each part of the message has the correct MIME type
168 shown in its Content-Type header. It may be repeated. It is
169 typically used to replace \*(lqapplication/octet-stream\*(rq with a
170 more descriptive MIME type. It may not be used for multipart and
171 message types.
172 .PP
173 .B mhfixmsg
174 applies one transformation unconditionally: it removes an extraneous
175 trailing semicolon from the parameter lists of MIME header fields.
176 .PP
177 The
178 .B \-verbose
179 switch directs
180 .B mhfixmsg
181 to output informational message for each transformation applied.
182 .PP
183 The return status of
184 .B mhfixmsg
185 is 0 if all of the requested transformations are performed, or
186 non-zero otherwise.
187 .RB ( mhfixmsg
188 will not decode to binary content, but a request to do so is
189 not considered a failure, and is noted with
190 .BR \-verbose .)
191 If a problem is detected with any one of multiple messages such that
192 the return status is non-zero, then none of the messages will be
193 modified.
194 .PP
195 The
196 .B \-file
197 .I file
198 switch directs
199 .B mhfixmsg
200 to use the specified
201 file as the source message, rather than a message from a folder.
202 Only one file argument may be provided. The
203 .B \-file
204 switch is implied if
205 .I file
206 is an absolute pathname.
207 If the file is \*(lq-\*(rq, then
208 .B mhfixmsg
209 accepts the source message on the standard input stream. If
210 the
211 .B \-outfile
212 switch is not enabled when using the standard input stream,
213 .B mhfixmsg
214 will not produce a transformed output message.
215 .PP
216 .BR mhfixmsg ,
217 by default, transforms the message in place. If the
218 .B \-outfile
219 switch is enabled, then
220 .B mhfixmsg
221 does not modify the input message or file, but instead places its
222 output in the specified file. An outfile name of \*(lq-\*(rq
223 specifies the standard output stream.
224 .PP
225 Combined with the
226 .B \-verbose
227 switch, the
228 .B \-outfile
229 switch can be used to show what transformations
230 .B mhfixmsg
231 would apply without actually applying them, e.g.,
232 .PP
233 .RS 5
234 mhfixmsg -outfile /dev/null -verbose
235 .RE
236 .PP
237 As always, this usage obeys any
238 .B mhfixmsg
239 switches in the user's profile.
240 .PP
241 .B \-outfile
242 can be combined with
243 .B rcvstore
244 to add a single transformed message to a different folder, e.g.,
245 .PP
246 .RS 5
247 mhfixmsg -outfile - | \\
248 .RS 0
249 %nmhlibexecdir%/rcvstore +folder
250 .RE
251 .RE
252 .SS Summary of Applicability
253 The transformations apply to the parts of a message depending on
254 content type and/or encoding as follows:
255 .PP
256 .RS 5
257 .nf
258 .ta \w'\-fixboundary 'u
259 \-decodetext base64 and quoted-printable encoded text parts
260 \-textcharset text/plain parts
261 \-reformat text parts that are not text/plain
262 \-fixboundary outermost multipart part
263 \-fixcte multipart part
264 \-fixtype all except multipart and message parts
265 .fi
266 .RE
267 .PP
268 .SS "Backup of Original Message/File"
269 If it applies any transformations to a message or file,
270 and the
271 .B \-outfile
272 switch is not used,
273 .B mhfixmsg
274 backs up the original the same way as
275 .BR rmm .
276 That is, it uses the
277 .I rmmproc
278 profile component, if present. If not present,
279 .B mhfixmsg
280 moves the original message to a backup file.
281 The
282 .B \-rmmproc
283 switch may be used to override this profile component. The
284 .B \-normmproc
285 switch disables the use of any
286 .I rmmproc
287 profile component and negates all prior
288 .B \-rmmproc
289 switches.
290 .PP
291 .SS "Integration with inc"
292 .B mhfixmsg
293 can be used as an add-hook, as described in %docdir%/README-HOOKS.
294 Note that add-hooks are called from all
295 .B nmh
296 programs that add a message to a folder, not just
297 .BR inc .
298 Alternatively, a simple shell alias or function can be used to
299 call
300 .B mhfixmsg
301 immediately after a successful invocation of
302 .BR inc .
303 One approach could be based on:
304 .PP
305 .RS 5
306 msgs=`inc -format '%(msg)'` && [ -n "$msgs" ] && scan $msgs && \
307 mhfixmsg -nochangecur $msgs
308 .RE
309 .PP
310 Another approach would rely on adding a sequence to Unseen-Sequence,
311 which
312 .B inc
313 sets with the newly incorporated messages. Those could then be
314 supplied to
315 .BR mhfixmsg .
316 .SS "Integration with procmail"
317 By way of example, here is an excerpt from a procmailrc file
318 that filters messages through
319 .B mhfixmsg
320 before storing them in the user's
321 .I nmh-workers
322 folder. It also stores the incoming message in the
323 .I Backups
324 folder in a filename generated by
325 .BR mkstemp ,
326 which is a non-POSIX utility to generate a temporary file.
327 Alternatively,
328 .B mhfixmsg
329 could be called on the message after it is stored.
330 .PP
331 .RS 5
332 .nf
333 .ta \w'\-fixboundary 'u
334 PATH = %bindir%:$PATH
335 MAILDIR = `mhparam path`
336 #### The Backups directory is relative to MAILDIR.
337 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
338 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
339 STORE = %nmhlibexecdir%/rcvstore
340
341 :0 w: nmh-workers/procmail.$LOCKEXT
342 * ^TOnmh-workers@nongnu.org
343 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
344 .fi
345 .RE
346 .PP
347 .SH FILES
348 .B mhfixmsg
349 looks for mhn.defaults in multiple locations: absolute pathnames are
350 accessed directly, tilde expansion is done on usernames, and files are
351 searched for in the user's
352 .I Mail
353 directory as specified in their profile. If not found there, the directory
354 .RI \*(lq %nmhetcdir% \*(rq
355 is checked.
356 .PP
357 .fc ^ ~
358 .nf
359 .ta \w'%nmhetcdir%/mhn.defaults 'u
360 ^$HOME/\&.mh\(ruprofile~^The user profile
361 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
362 .fi
363 .SH "PROFILE COMPONENTS"
364 .fc ^ ~
365 .nf
366 .ta 2.4i
367 .ta \w'ExtraBigProfileName 'u
368 ^Path:~^To determine the user's nmh directory
369 ^Current\-Folder:~^To find the default current folder
370 ^rmmproc:~^Program to delete original messages or files
371 .fi
372 .SH "SEE ALSO"
373 .IR inc (1),
374 .IR iconv (3),
375 .IR mh-profile (5),
376 .IR mhbuild (1),
377 .IR mhlist (1),
378 .IR mhparam (1),
379 .IR mhshow (1),
380 .IR mh-mkstemp (1),
381 .IR procmail (1),
382 .IR procmailrc (5),
383 .IR rcvstore (1),
384 .IR rmm (1)
385 .SH DEFAULTS
386 .nf
387 .RB ` +folder "' defaults to the current folder"
388 .RB ` msgs "' defaults to cur"
389 .RB ` "\-decodetext 8bit"'
390 .RB ` \-notextcharset '
391 .RB ` \-reformat '
392 .RB ` \-noreplacetextplain '
393 .RB ` \-fixboundary '
394 .RB ` \-fixcte '
395 .RB ` \-changecur '
396 .RB ` \-noverbose '
397 .fi
398 .SH CONTEXT
399 If a folder is given, it will become the current folder. The last
400 message selected from a folder will become the current message, unless
401 the
402 .B \-nochangecur
403 switch is enabled. If the
404 .B \-file
405 switch or an absolute pathname is used, the context will not be
406 modified.