1 .TH MHFIXMSG %manext1% "November 22, 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 ]
31 .RB [ \-changecur " | " \-nochangecur ]
32 .RB [ \-verbose " | " \-noverbose ]
38 rewrites MIME messages, applying specific transformations such as
39 decoding of MIME-encoded message parts and repairing invalid MIME
42 MIME messages are specified in RFC 2045 to RFC 2049
47 command is invaluable for viewing the content structure of MIME
50 passes non-MIME messages through without any transformations. If no
51 transformations apply to a MIME message, the original message or file
52 is not modified or removed.
56 switch enables a transformation to decode each base64 and
57 quoted-printable text message part to the selected 8bit or 7bit
58 encoding. If 7bit is selected for a base64 part but it will only fit
59 8bit, as defined by RFC 2045, then it will be decoded to 8bit
60 quoted-printable. Otherwise, if the decoded text would not fit the
61 selected encoding, the part is not decoded (and a message will be
68 switch is enabled, each carriage return character that precedes a
69 linefeed character is removed from text parts encoded in ASCII,
70 ISO-8859-x, UTF-8, or Windows-12xx.
74 switch specifies that all text/plain parts of the message(s)
75 should be converted to
77 Charset conversions require that
83 man page for how determine whether your
85 installation includes that.
86 To convert text parts other than text/plain, an external program can
93 switch enables a transformation for text parts in the message. For
94 each text part that is not text/plain and that does not have a
95 corresponding text/plain in a multipart/alternative part,
97 looks for a mhfixmsg-format-text/subtype profile entry that matches
98 the subtype of the part. If one is found and can be used to
99 successfully convert the part to text/plain,
101 inserts that text/plain part at the beginning of the containing
102 multipart/alternative part, if present. If not, it creates a
103 multipart/alternative part.
106 .B \-replacetextplain
107 switch broadens the applicability of
109 by always replacing a corresponding text/plain part, if one exists.
112 if enabled, the replacement will be shown as two steps: a removal of
113 the text/plain part followed by the usual insertion of a new part.
116 requires a profile entry for each text part subtype to be reformatted.
117 The mhfixmsg-format-text/subtype profile entries are based on external
118 conversion programs, and are used the same way that
120 uses its mhshow-show-text/subtype entries. When
122 is installed, it searches for a conversion program for text/html
123 content, and if one is found, inserts a mhfixmsg-format-text/html
124 entry in %nmhetcdir%/mhn.defaults. An entry of the same name in the
125 user's profile takes precedence. The user can add entries for
126 other text subtypes to their profile.
130 switch enables a transformation to repair the boundary portion of the
131 Content-Type header field of the message to match the boundaries of
132 the outermost multipart part of the message, if it does not. That
133 condition is indicated by a \*(lqbogus multipart content in
134 message\*(rq error message from
138 programs that parse MIME messages.
142 switch enables a transformation to change the
143 Content-Transfer-Encoding from an invalid value to 8bit in message
144 parts with a Content-Type of multipart, as required by RFC 2045,
145 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
146 7bit, 8bit, or binary\*(rq error message from
150 programs that parse MIME messages.
156 to output informational message for each transformation applied.
160 is 0 if all of the requested transformations are performed, or
163 will not decode to binary content, but a request to do so is
164 not considered a failure, and is noted with
166 If a problem is detected with any one of multiple messages such that
167 the return status is non-zero, then none of the messages will be
176 file as the source message, rather than a message from a folder.
177 Only one file argument may be provided. The
181 is an absolute pathname.
182 If the file is \*(lq-\*(rq, then
184 accepts the source message on the standard input stream. If
187 switch is not enabled when using the standard input stream,
189 will not produce a transformed output message.
192 by default, transforms the message in place. If the
194 switch is enabled, then
196 does not modify the input message or file, but instead places its
197 output in the specified file. An outfile name of \*(lq-\*(rq
198 specifies the standard output stream.
204 switch can be used to show what transformations
206 would apply without actually applying them, e.g.,
209 mhfixmsg -outfile /dev/null -verbose
212 As always, this usage obeys any
214 switches in the user's profile.
219 to add a single transformed message to a different folder, e.g.,
222 mhfixmsg -outfile - | \\
224 %nmhlibexecdir%/rcvstore +folder
227 .SS Summary of Applicability
228 The transformations apply to the parts of a message depending on
229 content type and/or encoding as follows:
233 .ta \w'\-fixboundary 'u
234 \-decodetext base64 and quoted-printable encoded text parts
235 \-textcharset text/plain parts
236 \-reformat text parts that are not text/plain
237 \-fixboundary outermost multipart part
238 \-fixcte multipart part
242 .SS "Backup of Original Message/File"
243 If it applies any transformations to a message or file,
248 backs up the original the same way as
252 profile component, if present. If not present,
254 moves the original message to a backup file.
257 switch may be used to override this profile component. The
259 switch disables the use of any
261 profile component and negates all prior
265 .SS "Integration with inc"
267 can be used as an add-hook, as described in %docdir%/README-HOOKS.
268 Note that add-hooks are called from all
270 programs that add a message to a folder, not just
272 Alternatively, a simple shell alias or function can be used to
275 immediately after a successful invocation of
277 One approach could be based on:
280 msgs=`inc -format '%(msg)'` && [ -n "$msgs" ] && scan $msgs && \
281 mhfixmsg -nochangecur $msgs
284 Another approach would rely on adding a sequence to Unseen-Sequence,
287 sets with the newly incorporated messages. Those could then be
290 .SS "Integration with procmail"
291 By way of example, here is an excerpt from a procmailrc file
292 that filters messages through
294 before storing them in the user's
296 folder. It also stores the incoming message in the
298 folder in a filename generated by
300 which is a non-POSIX utility to generate a temporary file.
303 could be called on the message after it is stored.
307 .ta \w'\-fixboundary 'u
308 PATH = %bindir%:$PATH
309 MAILDIR = `mhparam path`
310 #### The Backups directory is relative to MAILDIR.
311 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
312 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
313 STORE = %nmhlibexecdir%/rcvstore
315 :0 w: nmh-workers/procmail.$LOCKEXT
316 * ^TOnmh-workers@nongnu.org
317 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
323 looks for mhn.defaults in multiple locations: absolute pathnames are
324 accessed directly, tilde expansion is done on usernames, and files are
325 searched for in the user's
327 directory as specified in their profile. If not found there, the directory
328 .RI \*(lq %nmhetcdir% \*(rq
333 .ta \w'%nmhetcdir%/mhn.defaults 'u
334 ^$HOME/\&.mh\(ruprofile~^The user profile
335 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
337 .SH "PROFILE COMPONENTS"
341 .ta \w'ExtraBigProfileName 'u
342 ^Path:~^To determine the user's nmh directory
343 ^Current\-Folder:~^To find the default current folder
344 ^rmmproc:~^Program to delete original messages or files
361 .RB ` +folder "' defaults to the current folder"
362 .RB ` msgs "' defaults to cur"
363 .RB ` "\-decodetext 8bit"'
364 .RB ` \-notextcharset '
366 .RB ` \-noreplacetextplain '
367 .RB ` \-fixboundary '
373 If a folder is given, it will become the current folder. The last
374 message selected from a folder will become the current message, unless
377 switch is enabled. If the
379 switch or an absolute pathname is used, the context will not be