1 .TH MHFIXMSG %manext1% "February 24, 2016" "%nmhversion%"
6 mhfixmsg \- rewrite MIME messages with various transformations
13 .IR "absolute pathname" " | "
20 .IR "type/[subtype][,...]" ]
21 .RB [ \-crlflinebreaks " | " \-nocrlflinebreaks ]
24 .RB "| " \-notextcharset ]
25 .RB [ \-reformat " | " \-noreformat ]
26 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
27 .RB [ \-fixboundary " | " \-nofixboundary ]
28 .RB [ \-fixcte " | " \-nofixcte ]
36 .RB [ \-changecur " | " \-nochangecur ]
37 .RB [ \-verbose " | " \-noverbose ]
43 rewrites MIME messages, applying specific transformations such as
44 decoding of MIME-encoded message parts and repairing invalid MIME
47 MIME messages are specified in RFC 2045 to RFC 2049
52 command is invaluable for viewing the content structure of MIME
55 passes non-MIME messages through without any transformations. If no
56 transformations apply to a MIME message, the original message or file
57 is not modified or removed.
61 switch enables a transformation to decode each base64 and
62 quoted-printable text message part to the selected 8bit or 7bit
63 encoding. If 7bit is selected for a base64 part but it will only fit
64 8bit, as defined by RFC 2045, then it will be decoded to 8bit
65 quoted-printable. Otherwise, if the decoded text would not fit the
66 selected encoding, the part is not decoded (and a message will be
73 switch is enabled, each carriage return character that precedes a
74 linefeed character is removed from text parts encoded in ASCII,
75 ISO-8859-x, UTF-8, or Windows-12xx.
79 switch specifies the message parts, by type and optionally subtype,
82 applies. Its argument is a comma-separated list of type/subtype
83 elements. If an element does not contain a subtype, then
85 applies to all subtypes of the type. The default is
88 it can be overridden, e.g., with
93 to just text/plain parts.
95 By default, carriage return characters are preserved or inserted at
96 the end of each line of text content. The
98 switch selects this behavior and is enabled by default. The
100 switch causes carriage return characters to be stripped from, and not
101 inserted in, text content when it is decoded and encoded. Note that
102 its use can cause the generation of MIME messages that do not conform
103 with RFC 2046, §4.1.1, paragraph 1.
107 switch specifies that all text/plain parts of the message(s)
108 should be converted to
110 Charset conversions require that
116 man page for how determine whether your
118 installation includes that.
119 To convert text parts other than text/plain, an external program can
126 switch enables a transformation for text parts in the message. For
127 each text part that is not text/plain and that does not have a
128 corresponding text/plain in a multipart/alternative part,
130 looks for a mhfixmsg-format-text/subtype profile entry that matches
131 the subtype of the part. If one is found and can be used to
132 successfully convert the part to text/plain,
134 inserts that text/plain part at the beginning of the containing
135 multipart/alternative part, if present. If not, it creates a
136 multipart/alternative part.
140 switch, multipart/related parts are handled differently than
141 multipart/alternative. If the multipart/related has only a single
142 part that is not text/plain and can be converted to text/plain, a
143 text/plain part is added and the type of the part is changed to
144 multipart/alternative. If the multipart/related has more than one
145 part but does not have a text/plain part,
150 .B \-replacetextplain
151 switch broadens the applicability of
153 by always replacing a corresponding text/plain part, if one exists.
156 if enabled, the replacement will be shown as two steps: a removal of
157 the text/plain part followed by the usual insertion of a new part.
160 requires a profile entry for each text part subtype to be reformatted.
161 The mhfixmsg-format-text/subtype profile entries are based on external
162 conversion programs, and are used the same way that
164 uses its mhshow-show-text/subtype entries. When
166 is installed, it searches for a conversion program for text/html
167 content, and if one is found, inserts a mhfixmsg-format-text/html
168 entry in %nmhetcdir%/mhn.defaults. An entry of the same name in the
169 user's profile takes precedence. The user can add entries for
170 other text subtypes to their profile.
174 switch enables a transformation to repair the boundary portion of the
175 Content-Type header field of the message to match the boundaries of
176 the outermost multipart part of the message, if it does not. That
177 condition is indicated by a \*(lqbogus multipart content in
178 message\*(rq error message from
182 programs that parse MIME messages.
186 switch enables a transformation to change the
187 Content-Transfer-Encoding from an invalid value to 8bit in message
188 parts with a Content-Type of multipart, as required by RFC 2045,
189 §6.4. That condition is indicated by a \*(lqmust be encoded in
190 7bit, 8bit, or binary\*(rq error message from
194 programs that parse MIME messages.
198 switch ensures that each part of the message has the correct MIME type
199 shown in its Content-Type header. It may be repeated. It is
200 typically used to replace \*(lqapplication/octet-stream\*(rq with a
201 more descriptive MIME type. It may not be used for multipart and
205 applies one transformation unconditionally: it removes an extraneous
206 trailing semicolon from the parameter lists of MIME header fields.
212 to output informational message for each transformation applied.
216 is 0 if all of the requested transformations are performed, or
219 will not decode to binary content, but a request to do so is
220 not considered a failure, and is noted with
222 If a problem is detected with any one of multiple messages such that
223 the return status is non-zero, then none of the messages will be
232 file as the source message, rather than a message from a folder.
233 Only one file argument may be provided. The
237 is an absolute pathname.
238 If the file is \*(lq-\*(rq, then
240 accepts the source message on the standard input stream. If
243 switch is not enabled when using the standard input stream,
245 will not produce a transformed output message.
248 by default, transforms the message in place. If the
250 switch is enabled, then
252 does not modify the input message or file, but instead places its
253 output in the specified file. An outfile name of \*(lq-\*(rq
254 specifies the standard output stream.
260 switch can be used to show what transformations
262 would apply without actually applying them, e.g.,
265 mhfixmsg -outfile /dev/null -verbose
268 As always, this usage obeys any
270 switches in the user's profile.
275 to add a single transformed message to a different folder, e.g.,
278 mhfixmsg -outfile - | \\
280 %nmhlibexecdir%/rcvstore +folder
283 .SS Summary of Applicability
284 The transformations apply to the parts of a message depending on
285 content type and/or encoding as follows:
289 .ta \w'\-crlflinebreaks 'u
290 \-decodetext base64 and quoted-printable encoded text parts
291 \-decodetypes limits parts to which -decodetext applies
292 \-crlflinebreaks text parts
293 \-textcharset text/plain parts
294 \-reformat text parts that are not text/plain
295 \-fixboundary outermost multipart part
296 \-fixcte multipart part
297 \-fixtype all except multipart and message parts
301 .SS "Backup of Original Message/File"
302 If it applies any transformations to a message or file,
307 backs up the original the same way as
311 profile component, if present. If not present,
313 moves the original message to a backup file.
316 switch may be used to override this profile component. The
318 switch disables the use of any
320 profile component and negates all prior
324 .SS "Integration with inc"
326 can be used as an add-hook, as described in %docdir%/README-HOOKS.
327 Note that add-hooks are called from all
329 programs that add a message to a folder, not just
331 Alternatively, a simple shell alias or function can be used to
334 immediately after a successful invocation of
336 One approach could be based on:
339 msgs=`inc -format '%(msg)'` && [ -n "$msgs" ] && scan $msgs && \
340 mhfixmsg -nochangecur $msgs
343 Another approach would rely on adding a sequence to Unseen-Sequence,
346 sets with the newly incorporated messages. Those could then be
349 .SS "Integration with procmail"
350 By way of example, here is an excerpt from a procmailrc file
351 that filters messages through
353 before storing them in the user's
355 folder. It also stores the incoming message in the
357 folder in a filename generated by
359 which is a non-POSIX utility to generate a temporary file.
362 could be called on the message after it is stored.
366 .ta \w'\-fixboundary 'u
367 PATH = %bindir%:$PATH
368 MAILDIR = `mhparam path`
369 #### The Backups directory is relative to MAILDIR.
370 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
371 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
372 STORE = %nmhlibexecdir%/rcvstore
374 :0 w: nmh-workers/procmail.$LOCKEXT
375 * ^TOnmh-workers@nongnu.org
376 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
382 looks for mhn.defaults in multiple locations: absolute pathnames are
383 accessed directly, tilde expansion is done on usernames, and files are
384 searched for in the user's
386 directory as specified in their profile. If not found there, the directory
387 .RI \*(lq %nmhetcdir% \*(rq
392 .ta \w'%nmhetcdir%/mhn.defaults 'u
393 ^$HOME/\&.mh\(ruprofile~^The user profile
394 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
396 .SH "PROFILE COMPONENTS"
400 .ta \w'ExtraBigProfileName 'u
401 ^Path:~^To determine the user's nmh directory
402 ^Current\-Folder:~^To find the default current folder
403 ^rmmproc:~^Program to delete original messages or files
420 .RB ` +folder "' defaults to the current folder"
421 .RB ` msgs "' defaults to cur"
422 .RB ` "\-decodetext 8bit"'
423 .RB ` "\-decodetypes text"'
424 .RB ` \-crlflinebreaks '
425 .RB ` \-notextcharset '
427 .RB ` \-noreplacetextplain '
428 .RB ` \-fixboundary '
434 If a folder is given, it will become the current folder. The last
435 message selected from a folder will become the current message, unless
438 switch is enabled. If the
440 switch or an absolute pathname is used, the context will not be