1 .TH MHFIXMSG %manext1% "December 25, 2014" "%nmhversion%"
6 mhfixmsg \- rewrite MIME messages with various transformations
13 .IR "absolute pathname" " | "
21 .RB "| " \-notextcharset ]
22 .RB [ \-reformat " | " \-noreformat ]
23 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
24 .RB [ \-fixboundary " | " \-nofixboundary ]
25 .RB [ \-fixcte " | " \-nofixcte ]
33 .RB [ \-changecur " | " \-nochangecur ]
34 .RB [ \-verbose " | " \-noverbose ]
40 rewrites MIME messages, applying specific transformations such as
41 decoding of MIME-encoded message parts and repairing invalid MIME
44 MIME messages are specified in RFC 2045 to RFC 2049
49 command is invaluable for viewing the content structure of MIME
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.
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
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.
76 switch specifies that all text/plain parts of the message(s)
77 should be converted to
79 Charset conversions require that
85 man page for how determine whether your
87 installation includes that.
88 To convert text parts other than text/plain, an external program can
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,
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,
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.
108 .B \-replacetextplain
109 switch broadens the applicability of
111 by always replacing a corresponding text/plain part, if one exists.
114 if enabled, the replacement will be shown as two steps: a removal of
115 the text/plain part followed by the usual insertion of a new part.
118 requires a profile entry for each text part subtype to be reformatted.
119 The mhfixmsg-format-text/subtype profile entries are based on external
120 conversion programs, and are used the same way that
122 uses its mhshow-show-text/subtype entries. When
124 is installed, it searches for a conversion program for text/html
125 content, and if one is found, inserts a mhfixmsg-format-text/html
126 entry in %nmhetcdir%/mhn.defaults. An entry of the same name in the
127 user's profile takes precedence. The user can add entries for
128 other text subtypes to their profile.
132 switch enables a transformation to repair the boundary portion of the
133 Content-Type header field of the message to match the boundaries of
134 the outermost multipart part of the message, if it does not. That
135 condition is indicated by a \*(lqbogus multipart content in
136 message\*(rq error message from
140 programs that parse MIME messages.
144 switch enables a transformation to change the
145 Content-Transfer-Encoding from an invalid value to 8bit in message
146 parts with a Content-Type of multipart, as required by RFC 2045,
147 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
148 7bit, 8bit, or binary\*(rq error message from
152 programs that parse MIME messages.
156 switch ensures that each part of the message has the correct MIME type
157 shown in its Content-Type header. It may be repeated. It is
158 typically used to replace \*(lqapplication/octet-stream\*(rq with a
159 more descriptive MIME type. It may not be used for multipart and
163 applies one transformation unconditionally: it removes an extraneous
164 trailing semicolon from the parameter lists of MIME header fields.
170 to output informational message for each transformation applied.
174 is 0 if all of the requested transformations are performed, or
177 will not decode to binary content, but a request to do so is
178 not considered a failure, and is noted with
180 If a problem is detected with any one of multiple messages such that
181 the return status is non-zero, then none of the messages will be
190 file as the source message, rather than a message from a folder.
191 Only one file argument may be provided. The
195 is an absolute pathname.
196 If the file is \*(lq-\*(rq, then
198 accepts the source message on the standard input stream. If
201 switch is not enabled when using the standard input stream,
203 will not produce a transformed output message.
206 by default, transforms the message in place. If the
208 switch is enabled, then
210 does not modify the input message or file, but instead places its
211 output in the specified file. An outfile name of \*(lq-\*(rq
212 specifies the standard output stream.
218 switch can be used to show what transformations
220 would apply without actually applying them, e.g.,
223 mhfixmsg -outfile /dev/null -verbose
226 As always, this usage obeys any
228 switches in the user's profile.
233 to add a single transformed message to a different folder, e.g.,
236 mhfixmsg -outfile - | \\
238 %nmhlibexecdir%/rcvstore +folder
241 .SS Summary of Applicability
242 The transformations apply to the parts of a message depending on
243 content type and/or encoding as follows:
247 .ta \w'\-fixboundary 'u
248 \-decodetext base64 and quoted-printable encoded text parts
249 \-textcharset text/plain parts
250 \-reformat text parts that are not text/plain
251 \-fixboundary outermost multipart part
252 \-fixcte multipart part
253 \-fixtype all except multipart and message parts
257 .SS "Backup of Original Message/File"
258 If it applies any transformations to a message or file,
263 backs up the original the same way as
267 profile component, if present. If not present,
269 moves the original message to a backup file.
272 switch may be used to override this profile component. The
274 switch disables the use of any
276 profile component and negates all prior
280 .SS "Integration with inc"
282 can be used as an add-hook, as described in %docdir%/README-HOOKS.
283 Note that add-hooks are called from all
285 programs that add a message to a folder, not just
287 Alternatively, a simple shell alias or function can be used to
290 immediately after a successful invocation of
292 One approach could be based on:
295 msgs=`inc -format '%(msg)'` && [ -n "$msgs" ] && scan $msgs && \
296 mhfixmsg -nochangecur $msgs
299 Another approach would rely on adding a sequence to Unseen-Sequence,
302 sets with the newly incorporated messages. Those could then be
305 .SS "Integration with procmail"
306 By way of example, here is an excerpt from a procmailrc file
307 that filters messages through
309 before storing them in the user's
311 folder. It also stores the incoming message in the
313 folder in a filename generated by
315 which is a non-POSIX utility to generate a temporary file.
318 could be called on the message after it is stored.
322 .ta \w'\-fixboundary 'u
323 PATH = %bindir%:$PATH
324 MAILDIR = `mhparam path`
325 #### The Backups directory is relative to MAILDIR.
326 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
327 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
328 STORE = %nmhlibexecdir%/rcvstore
330 :0 w: nmh-workers/procmail.$LOCKEXT
331 * ^TOnmh-workers@nongnu.org
332 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
338 looks for mhn.defaults in multiple locations: absolute pathnames are
339 accessed directly, tilde expansion is done on usernames, and files are
340 searched for in the user's
342 directory as specified in their profile. If not found there, the directory
343 .RI \*(lq %nmhetcdir% \*(rq
348 .ta \w'%nmhetcdir%/mhn.defaults 'u
349 ^$HOME/\&.mh\(ruprofile~^The user profile
350 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
352 .SH "PROFILE COMPONENTS"
356 .ta \w'ExtraBigProfileName 'u
357 ^Path:~^To determine the user's nmh directory
358 ^Current\-Folder:~^To find the default current folder
359 ^rmmproc:~^Program to delete original messages or files
376 .RB ` +folder "' defaults to the current folder"
377 .RB ` msgs "' defaults to cur"
378 .RB ` "\-decodetext 8bit"'
379 .RB ` \-notextcharset '
381 .RB ` \-noreplacetextplain '
382 .RB ` \-fixboundary '
388 If a folder is given, it will become the current folder. The last
389 message selected from a folder will become the current message, unless
392 switch is enabled. If the
394 switch or an absolute pathname is used, the context will not be