1 .TH MHFIXMSG %manext1% "October 27, 2013" "%nmhversion%"
6 mhfixmsg \- rewrite MIME messages with various transformations
13 .IR "absolute pathname" " | "
21 .RB "| " \-notextcodeset ]
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 Codeset conversions require that
80 To convert text parts other than text/plain, an external program can
87 switch enables a transformation for text parts in the message. For
88 each text part that is not text/plain and that does not have a
89 corresponding text/plain in a multipart/alternative part,
91 looks for a mhfixmsg-format-text/subtype profile entry that matches
92 the subtype of the part. If one is found and can be used to
93 successfully convert the part to text/plain,
95 inserts that text/plain part at the beginning of the containing
96 multipart/alternative part, if present. If not, it creates a
97 multipart/alternative part.
100 .B \-replacetextplain
101 switch broadens the applicability of
103 by always replacing a corresponding text/plain part, if one exists.
106 if enabled, the replacement will be shown as two steps: a removal of
107 the text/plain part followed by the usual insertion of a new part.
110 requires a profile entry for each text part subtype to be reformatted.
111 The mhfixmsg-format-text/subtype profile entries are based on external
112 conversion programs, and are used the same way that
114 uses its mhshow-show-text/subtype entries. When
116 is installed, it searches for a conversion program for text/html
117 content, and if one is found, inserts a mhfixmsg-format-text/html
118 entry in %etcdir%/mhn.defaults. An entry of the same name in the
119 user's profile takes precedence. The user can add entries for
120 other text subtypes to their profile.
124 switch enables a transformation to repair the boundary portion of the
125 Content-Type header field of the message to match the boundaries of
126 the outermost multipart part of the message, if it does not. That
127 condition is indicated by a \*(lqbogus multipart content in
128 message\*(rq error message from
132 programs that parse MIME messages.
136 switch enables a transformation to change the
137 Content-Transfer-Encoding from an invalid value to 8bit in message
138 parts with a Content-Type of multipart, as required by RFC 2045,
139 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
140 7bit, 8bit, or binary\*(rq error message from
144 programs that parse MIME messages.
150 to output informational message for each transformation applied.
158 file as the source message, rather than a message from a folder.
159 Only one file argument may be provided. The
163 is an absolute pathname.
164 If the file is \*(lq-\*(rq, then
166 accepts the source message on the standard input stream. If
169 switch is not enabled when using the standard input stream,
171 will not produce a transformed output message.
174 by default, transforms the message in place. If the
176 switch is enabled, then
178 does not modify the input message or file, but instead places its
179 output in the specified file. An outfile name of \*(lq-\*(rq
180 specifies the standard output stream.
186 switch can be used to show what transformations
188 would apply without actually applying them, e.g.,
191 mhfixmsg -outfile /dev/null -verbose
194 As always, this usage obeys any
196 switches in the user's profile.
201 to add a single transformed message to a different folder, e.g.,
204 mhfixmsg -outfile - | \\
206 %libdir%/rcvstore +folder
209 .SS Summary of Applicability
210 The transformations apply to the parts of a message depending on
211 content type and/or encoding as follows:
215 .ta \w'\-fixboundary 'u
216 \-decodetext base64 and quoted-printable encoded text parts
217 \-textcodeset text/plain parts
218 \-reformat text parts that are not text/plain
219 \-fixboundary outermost multipart part
220 \-fixcte multipart part
224 .SS "Backup of Original Message/File"
225 If it applies any transformations to a message or file,
230 backs up the original the same way as
234 profile component, if present. If not present,
236 moves the original message to a backup file.
239 switch may be used to override this profile component. The
241 switch disables the use of any
243 profile component and negates all prior
247 .SS "Integration with inc"
249 can be used as an add-hook, as described in %docdir%/README-HOOKS.
250 Note that add-hooks are called from all
252 programs that add a message to a folder, not just
254 Alternatively, a simple shell alias or function can be used to
257 immediately after a successful invocation of
259 For example, with bash:
262 alias inc='inc && mhfixmsg'
265 .SS "Integration with procmail"
266 By way of example, here is an excerpt from a procmailrc file
267 that filters messages through
269 before storing them in the user's
271 folder. It also stores the incoming message in the
273 folder in a filename generated by
275 which is a non-POSIX utility to generate a temporary file.
276 If you do not have that utility, then the
278 function could form the basis for a substitute. Or,
280 could be called on the message after it is stored.
284 .ta \w'\-fixboundary 'u
285 PATH = %bindir%:$PATH
286 MAILDIR = `mhparam path`
287 MKTEMP = 'mktemp Backups/mhfixmsg.XXXXXXXX'
288 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
289 STORE = %libdir%/rcvstore
291 :0 w: nmh-worker/procmail.$LOCKEXT
292 * ^TOnmh-workers@nongnu.org
293 | tee `$MKTEMP` | $MHFIXMSG | $STORE +nmh-workers
299 looks for mhn.defaults in multiple locations: absolute pathnames are
300 accessed directly, tilde expansion is done on usernames, and files are
301 searched for in the user's
303 directory as specified in their profile. If not found there, the directory
304 .RI \*(lq %etcdir% \*(rq
309 .ta \w'%etcdir%/mhn.defaults 'u
310 ^$HOME/\&.mh\(ruprofile~^The user profile
311 ^%etcdir%/mhn.defaults~^Default mhfixmsg conversion entries
313 .SH "PROFILE COMPONENTS"
317 .ta \w'ExtraBigProfileName 'u
318 ^Path:~^To determine the user's nmh directory
319 ^Current\-Folder:~^To find the default current folder
320 ^rmmproc:~^Program to delete original messages or files
335 .RB ` +folder "' defaults to the current folder"
336 .RB ` msgs "' defaults to cur"
337 .RB ` "\-decodetext 8bit"'
338 .RB ` \-notextcodeset '
340 .RB ` \-noreplacetextplain '
341 .RB ` \-fixboundary '
346 If a folder is given, it will become the current folder. The last
347 message selected from a folder will become the current message. If
350 switch or an absolute pathname is used, the context will not be