1 .TH MHFIXMSG %manext1% "March 16, 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 [ \-verbose " | " \-noverbose ]
37 rewrites MIME messages, applying specific transformations such as
38 decoding of MIME-encoded message parts and repairing invalid MIME
41 MIME messages are specified in RFC 2045 to RFC 2049
46 command is invaluable for viewing the content structure of MIME
49 passes non-MIME messages through without any transformations. If no
50 transformations apply to a MIME message, the original message or file
51 is not modified or removed.
55 switch enables a transformation to decode each base64 and
56 quoted-printable text message part to the selected 8bit or 7bit
57 encoding. If 7bit is selected for a base64 part but it will only fit
58 8bit, as defined by RFC 2045, then it will be decoded to 8bit
59 quoted-printable. Otherwise, if the decoded text would not fit the
60 selected encoding, the part is not decoded (and a message will be
67 switch is enabled, each carriage return character that precedes a
68 linefeed character is removed from text parts encoded in ASCII,
69 ISO-8859-x, UTF-8, or Windows-12xx.
73 switch specifies that all text/plain parts of the message(s)
74 should be converted to
76 Charset conversions require that
82 man page for how determine whether your
84 installation includes that.
85 To convert text parts other than text/plain, an external program can
92 switch enables a transformation for text parts in the message. For
93 each text part that is not text/plain and that does not have a
94 corresponding text/plain in a multipart/alternative part,
96 looks for a mhfixmsg-format-text/subtype profile entry that matches
97 the subtype of the part. If one is found and can be used to
98 successfully convert the part to text/plain,
100 inserts that text/plain part at the beginning of the containing
101 multipart/alternative part, if present. If not, it creates a
102 multipart/alternative part.
105 .B \-replacetextplain
106 switch broadens the applicability of
108 by always replacing a corresponding text/plain part, if one exists.
111 if enabled, the replacement will be shown as two steps: a removal of
112 the text/plain part followed by the usual insertion of a new part.
115 requires a profile entry for each text part subtype to be reformatted.
116 The mhfixmsg-format-text/subtype profile entries are based on external
117 conversion programs, and are used the same way that
119 uses its mhshow-show-text/subtype entries. When
121 is installed, it searches for a conversion program for text/html
122 content, and if one is found, inserts a mhfixmsg-format-text/html
123 entry in %etcdir%/mhn.defaults. An entry of the same name in the
124 user's profile takes precedence. The user can add entries for
125 other text subtypes to their profile.
129 switch enables a transformation to repair the boundary portion of the
130 Content-Type header field of the message to match the boundaries of
131 the outermost multipart part of the message, if it does not. That
132 condition is indicated by a \*(lqbogus multipart content in
133 message\*(rq error message from
137 programs that parse MIME messages.
141 switch enables a transformation to change the
142 Content-Transfer-Encoding from an invalid value to 8bit in message
143 parts with a Content-Type of multipart, as required by RFC 2045,
144 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
145 7bit, 8bit, or binary\*(rq error message from
149 programs that parse MIME messages.
155 to output informational message for each transformation applied.
163 file as the source message, rather than a message from a folder.
164 Only one file argument may be provided. The
168 is an absolute pathname.
169 If the file is \*(lq-\*(rq, then
171 accepts the source message on the standard input stream. If
174 switch is not enabled when using the standard input stream,
176 will not produce a transformed output message.
179 by default, transforms the message in place. If the
181 switch is enabled, then
183 does not modify the input message or file, but instead places its
184 output in the specified file. An outfile name of \*(lq-\*(rq
185 specifies the standard output stream.
191 switch can be used to show what transformations
193 would apply without actually applying them, e.g.,
196 mhfixmsg -outfile /dev/null -verbose
199 As always, this usage obeys any
201 switches in the user's profile.
206 to add a single transformed message to a different folder, e.g.,
209 mhfixmsg -outfile - | \\
211 %libdir%/rcvstore +folder
214 .SS Summary of Applicability
215 The transformations apply to the parts of a message depending on
216 content type and/or encoding as follows:
220 .ta \w'\-fixboundary 'u
221 \-decodetext base64 and quoted-printable encoded text parts
222 \-textcharset text/plain parts
223 \-reformat text parts that are not text/plain
224 \-fixboundary outermost multipart part
225 \-fixcte multipart part
229 .SS "Backup of Original Message/File"
230 If it applies any transformations to a message or file,
235 backs up the original the same way as
239 profile component, if present. If not present,
241 moves the original message to a backup file.
244 switch may be used to override this profile component. The
246 switch disables the use of any
248 profile component and negates all prior
252 .SS "Integration with inc"
254 can be used as an add-hook, as described in %docdir%/README-HOOKS.
255 Note that add-hooks are called from all
257 programs that add a message to a folder, not just
259 Alternatively, a simple shell alias or function can be used to
262 immediately after a successful invocation of
264 For example, with bash:
267 alias inc='inc && mhfixmsg'
270 .SS "Integration with procmail"
271 By way of example, here is an excerpt from a procmailrc file
272 that filters messages through
274 before storing them in the user's
276 folder. It also stores the incoming message in the
278 folder in a filename generated by
280 which is a non-POSIX utility to generate a temporary file.
281 If you do not have that utility, then the
283 function could form the basis for a substitute. Or,
285 could be called on the message after it is stored.
289 .ta \w'\-fixboundary 'u
290 PATH = %bindir%:$PATH
291 MAILDIR = `mhparam path`
292 MKTEMP = 'mktemp Backups/mhfixmsg.XXXXXXXX'
293 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
294 STORE = %libdir%/rcvstore
296 :0 w: nmh-worker/procmail.$LOCKEXT
297 * ^TOnmh-workers@nongnu.org
298 | tee `$MKTEMP` | $MHFIXMSG | $STORE +nmh-workers
304 looks for mhn.defaults in multiple locations: absolute pathnames are
305 accessed directly, tilde expansion is done on usernames, and files are
306 searched for in the user's
308 directory as specified in their profile. If not found there, the directory
309 .RI \*(lq %etcdir% \*(rq
314 .ta \w'%etcdir%/mhn.defaults 'u
315 ^$HOME/\&.mh\(ruprofile~^The user profile
316 ^%etcdir%/mhn.defaults~^Default mhfixmsg conversion entries
318 .SH "PROFILE COMPONENTS"
322 .ta \w'ExtraBigProfileName 'u
323 ^Path:~^To determine the user's nmh directory
324 ^Current\-Folder:~^To find the default current folder
325 ^rmmproc:~^Program to delete original messages or files
342 .RB ` +folder "' defaults to the current folder"
343 .RB ` msgs "' defaults to cur"
344 .RB ` "\-decodetext 8bit"'
345 .RB ` \-notextcharset '
347 .RB ` \-noreplacetextplain '
348 .RB ` \-fixboundary '
353 If a folder is given, it will become the current folder. The last
354 message selected from a folder will become the current message. If
357 switch or an absolute pathname is used, the context will not be