1 .TH MHFIXMSG %manext1% "February 20, 2016" "%nmhversion%"
6 mhfixmsg \- rewrite MIME messages with various transformations
13 .IR "absolute pathname" " | "
20 .IR "type/[subtype][,...]" ]
23 .RB "| " \-notextcharset ]
24 .RB [ \-reformat " | " \-noreformat ]
25 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
26 .RB [ \-fixboundary " | " \-nofixboundary ]
27 .RB [ \-fixcte " | " \-nofixcte ]
35 .RB [ \-changecur " | " \-nochangecur ]
36 .RB [ \-verbose " | " \-noverbose ]
42 rewrites MIME messages, applying specific transformations such as
43 decoding of MIME-encoded message parts and repairing invalid MIME
46 MIME messages are specified in RFC 2045 to RFC 2049
51 command is invaluable for viewing the content structure of MIME
54 passes non-MIME messages through without any transformations. If no
55 transformations apply to a MIME message, the original message or file
56 is not modified or removed.
60 switch enables a transformation to decode each base64 and
61 quoted-printable text message part to the selected 8bit or 7bit
62 encoding. If 7bit is selected for a base64 part but it will only fit
63 8bit, as defined by RFC 2045, then it will be decoded to 8bit
64 quoted-printable. Otherwise, if the decoded text would not fit the
65 selected encoding, the part is not decoded (and a message will be
72 switch is enabled, each carriage return character that precedes a
73 linefeed character is removed from text parts encoded in ASCII,
74 ISO-8859-x, UTF-8, or Windows-12xx.
78 switch specifies the message parts, by type and optionally subtype,
81 applies. Its argument is a comma-separated list of type/subtype
82 elements. If an element does not contain a subtype, then
84 applies to all subtypes of the type. The default is
87 it can be overridden, e.g., with
92 to just text/plain parts.
96 switch specifies that all text/plain parts of the message(s)
97 should be converted to
99 Charset conversions require that
105 man page for how determine whether your
107 installation includes that.
108 To convert text parts other than text/plain, an external program can
115 switch enables a transformation for text parts in the message. For
116 each text part that is not text/plain and that does not have a
117 corresponding text/plain in a multipart/alternative part,
119 looks for a mhfixmsg-format-text/subtype profile entry that matches
120 the subtype of the part. If one is found and can be used to
121 successfully convert the part to text/plain,
123 inserts that text/plain part at the beginning of the containing
124 multipart/alternative part, if present. If not, it creates a
125 multipart/alternative part.
129 switch, multipart/related parts are handled differently than
130 multipart/alternative. If the multipart/related has only a single
131 part that is not text/plain and can be converted to text/plain, a
132 text/plain part is added and the type of the part is changed to
133 multipart/alternative. If the multipart/related has more than one
134 part but does not have a text/plain part,
139 .B \-replacetextplain
140 switch broadens the applicability of
142 by always replacing a corresponding text/plain part, if one exists.
145 if enabled, the replacement will be shown as two steps: a removal of
146 the text/plain part followed by the usual insertion of a new part.
149 requires a profile entry for each text part subtype to be reformatted.
150 The mhfixmsg-format-text/subtype profile entries are based on external
151 conversion programs, and are used the same way that
153 uses its mhshow-show-text/subtype entries. When
155 is installed, it searches for a conversion program for text/html
156 content, and if one is found, inserts a mhfixmsg-format-text/html
157 entry in %nmhetcdir%/mhn.defaults. An entry of the same name in the
158 user's profile takes precedence. The user can add entries for
159 other text subtypes to their profile.
163 switch enables a transformation to repair the boundary portion of the
164 Content-Type header field of the message to match the boundaries of
165 the outermost multipart part of the message, if it does not. That
166 condition is indicated by a \*(lqbogus multipart content in
167 message\*(rq error message from
171 programs that parse MIME messages.
175 switch enables a transformation to change the
176 Content-Transfer-Encoding from an invalid value to 8bit in message
177 parts with a Content-Type of multipart, as required by RFC 2045,
178 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
179 7bit, 8bit, or binary\*(rq error message from
183 programs that parse MIME messages.
187 switch ensures that each part of the message has the correct MIME type
188 shown in its Content-Type header. It may be repeated. It is
189 typically used to replace \*(lqapplication/octet-stream\*(rq with a
190 more descriptive MIME type. It may not be used for multipart and
194 applies one transformation unconditionally: it removes an extraneous
195 trailing semicolon from the parameter lists of MIME header fields.
201 to output informational message for each transformation applied.
205 is 0 if all of the requested transformations are performed, or
208 will not decode to binary content, but a request to do so is
209 not considered a failure, and is noted with
211 If a problem is detected with any one of multiple messages such that
212 the return status is non-zero, then none of the messages will be
221 file as the source message, rather than a message from a folder.
222 Only one file argument may be provided. The
226 is an absolute pathname.
227 If the file is \*(lq-\*(rq, then
229 accepts the source message on the standard input stream. If
232 switch is not enabled when using the standard input stream,
234 will not produce a transformed output message.
237 by default, transforms the message in place. If the
239 switch is enabled, then
241 does not modify the input message or file, but instead places its
242 output in the specified file. An outfile name of \*(lq-\*(rq
243 specifies the standard output stream.
249 switch can be used to show what transformations
251 would apply without actually applying them, e.g.,
254 mhfixmsg -outfile /dev/null -verbose
257 As always, this usage obeys any
259 switches in the user's profile.
264 to add a single transformed message to a different folder, e.g.,
267 mhfixmsg -outfile - | \\
269 %nmhlibexecdir%/rcvstore +folder
272 .SS Summary of Applicability
273 The transformations apply to the parts of a message depending on
274 content type and/or encoding as follows:
278 .ta \w'\-fixboundary 'u
279 \-decodetext base64 and quoted-printable encoded text parts
280 \-decodetypes limits parts to which -decodetext applies
281 \-textcharset text/plain parts
282 \-reformat text parts that are not text/plain
283 \-fixboundary outermost multipart part
284 \-fixcte multipart part
285 \-fixtype all except multipart and message parts
289 .SS "Backup of Original Message/File"
290 If it applies any transformations to a message or file,
295 backs up the original the same way as
299 profile component, if present. If not present,
301 moves the original message to a backup file.
304 switch may be used to override this profile component. The
306 switch disables the use of any
308 profile component and negates all prior
312 .SS "Integration with inc"
314 can be used as an add-hook, as described in %docdir%/README-HOOKS.
315 Note that add-hooks are called from all
317 programs that add a message to a folder, not just
319 Alternatively, a simple shell alias or function can be used to
322 immediately after a successful invocation of
324 One approach could be based on:
327 msgs=`inc -format '%(msg)'` && [ -n "$msgs" ] && scan $msgs && \
328 mhfixmsg -nochangecur $msgs
331 Another approach would rely on adding a sequence to Unseen-Sequence,
334 sets with the newly incorporated messages. Those could then be
337 .SS "Integration with procmail"
338 By way of example, here is an excerpt from a procmailrc file
339 that filters messages through
341 before storing them in the user's
343 folder. It also stores the incoming message in the
345 folder in a filename generated by
347 which is a non-POSIX utility to generate a temporary file.
350 could be called on the message after it is stored.
354 .ta \w'\-fixboundary 'u
355 PATH = %bindir%:$PATH
356 MAILDIR = `mhparam path`
357 #### The Backups directory is relative to MAILDIR.
358 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
359 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
360 STORE = %nmhlibexecdir%/rcvstore
362 :0 w: nmh-workers/procmail.$LOCKEXT
363 * ^TOnmh-workers@nongnu.org
364 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
370 looks for mhn.defaults in multiple locations: absolute pathnames are
371 accessed directly, tilde expansion is done on usernames, and files are
372 searched for in the user's
374 directory as specified in their profile. If not found there, the directory
375 .RI \*(lq %nmhetcdir% \*(rq
380 .ta \w'%nmhetcdir%/mhn.defaults 'u
381 ^$HOME/\&.mh\(ruprofile~^The user profile
382 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
384 .SH "PROFILE COMPONENTS"
388 .ta \w'ExtraBigProfileName 'u
389 ^Path:~^To determine the user's nmh directory
390 ^Current\-Folder:~^To find the default current folder
391 ^rmmproc:~^Program to delete original messages or files
408 .RB ` +folder "' defaults to the current folder"
409 .RB ` msgs "' defaults to cur"
410 .RB ` "\-decodetext 8bit"'
411 .RB ` "\-decodetypes text"'
412 .RB ` \-notextcharset '
414 .RB ` \-noreplacetextplain '
415 .RB ` \-fixboundary '
421 If a folder is given, it will become the current folder. The last
422 message selected from a folder will become the current message, unless
425 switch is enabled. If the
427 switch or an absolute pathname is used, the context will not be