]> diplodocus.org Git - nmh/blob - man/mhfixmsg.man
de5cc611e041d4736d63347a34fffbb47f34f221
[nmh] / man / mhfixmsg.man
1 .TH MHFIXMSG %manext1% "November 19, 2014" "%nmhversion%"
2 .\"
3 .\" %nmhwarning%
4 .\"
5 .SH NAME
6 mhfixmsg \- rewrite MIME messages with various transformations
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B mhfixmsg
11 .RI [ +folder ]
12 .RI [ msgs " | "
13 .IR "absolute pathname" " | "
14 .RB \-file
15 .IR file ]
16 .RB [ \-decodetext
17 8bit/7bit |
18 .BR \-nodecodetext ]
19 .RB [ \-textcharset
20 .I charset
21 .RB "| " \-notextcharset ]
22 .RB [ \-reformat " | " \-noreformat ]
23 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
24 .RB [ \-fixboundary " | " \-nofixboundary ]
25 .RB [ \-fixcte " | " \-nofixcte ]
26 .RB [ \-outfile
27 .IR outfile ]
28 .RB [ \-rmmproc
29 .IR program ]
30 .RB [ \-normmproc ]
31 .RB [ \-changecur " | " \-nochangecur ]
32 .RB [ \-verbose " | " \-noverbose ]
33 .RB [ \-version ]
34 .RB [ \-help ]
35 .ad
36 .SH DESCRIPTION
37 .B mhfixmsg
38 rewrites MIME messages, applying specific transformations such as
39 decoding of MIME-encoded message parts and repairing invalid MIME
40 headers.
41 .PP
42 MIME messages are specified in RFC 2045 to RFC 2049
43 (see
44 .IR mhbuild (1)).
45 The
46 .B mhlist
47 command is invaluable for viewing the content structure of MIME
48 messages.
49 .B mhfixmsg
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.
53 .PP
54 The
55 .B \-decodetext
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
62 displayed if
63 .B \-verbose
64 is enabled).
65 .PP
66 When the
67 .B \-decodetext
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.
71 .PP
72 The
73 .B \-textcharset
74 switch specifies that all text/plain parts of the message(s)
75 should be converted to
76 .IR charset .
77 Charset conversions require that
78 .B nmh
79 be built with
80 .IR iconv (3);
81 see the
82 .BR mhparam (1)
83 man page for how determine whether your
84 .B nmh
85 installation includes that.
86 To convert text parts other than text/plain, an external program can
87 be used, via the
88 .B \-reformat
89 switch.
90 .PP
91 The
92 .B \-reformat
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,
96 .B mhfixmsg
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,
100 .B mhfixmsg
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.
104 .PP
105 The
106 .B \-replacetextplain
107 switch broadens the applicability of
108 .B \-reformat
109 by always replacing a corresponding text/plain part, if one exists.
110 If
111 .B \-verbose
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.
114 .PP
115 .B \-reformat
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
119 .B mhshow
120 uses its mhshow-show-text/subtype entries. When
121 .B nmh
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.
127 .PP
128 The
129 .B \-fixboundary
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
135 .B mhlist
136 and other
137 .B nmh
138 programs that parse MIME messages.
139 .PP
140 The
141 .B \-fixcte
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
147 .B mhlist
148 and other
149 .B nmh
150 programs that parse MIME messages.
151 .PP
152 The
153 .B \-verbose
154 switch directs
155 .B mhfixmsg
156 to output informational message for each transformation applied.
157 .PP
158 The
159 .B \-file
160 .I file
161 switch directs
162 .B mhfixmsg
163 to use the specified
164 file as the source message, rather than a message from a folder.
165 Only one file argument may be provided. The
166 .B \-file
167 switch is implied if
168 .I file
169 is an absolute pathname.
170 If the file is \*(lq-\*(rq, then
171 .B mhfixmsg
172 accepts the source message on the standard input stream. If
173 the
174 .B \-outfile
175 switch is not enabled when using the standard input stream,
176 .B mhfixmsg
177 will not produce a transformed output message.
178 .PP
179 .BR mhfixmsg ,
180 by default, transforms the message in place. If the
181 .B \-outfile
182 switch is enabled, then
183 .B mhfixmsg
184 does not modify the input message or file, but instead places its
185 output in the specified file. An outfile name of \*(lq-\*(rq
186 specifies the standard output stream.
187 .PP
188 Combined with the
189 .B \-verbose
190 switch, the
191 .B \-outfile
192 switch can be used to show what transformations
193 .B mhfixmsg
194 would apply without actually applying them, e.g.,
195 .PP
196 .RS 5
197 mhfixmsg -outfile /dev/null -verbose
198 .RE
199 .PP
200 As always, this usage obeys any
201 .B mhfixmsg
202 switches in the user's profile.
203 .PP
204 .B \-outfile
205 can be combined with
206 .B rcvstore
207 to add a single transformed message to a different folder, e.g.,
208 .PP
209 .RS 5
210 mhfixmsg -outfile - | \\
211 .RS 0
212 %nmhlibexecdir%/rcvstore +folder
213 .RE
214 .RE
215 .SS Summary of Applicability
216 The transformations apply to the parts of a message depending on
217 content type and/or encoding as follows:
218 .PP
219 .RS 5
220 .nf
221 .ta \w'\-fixboundary 'u
222 \-decodetext base64 and quoted-printable encoded text parts
223 \-textcharset text/plain parts
224 \-reformat text parts that are not text/plain
225 \-fixboundary outermost multipart part
226 \-fixcte multipart part
227 .fi
228 .RE
229 .PP
230 .SS "Backup of Original Message/File"
231 If it applies any transformations to a message or file,
232 and the
233 .B \-outfile
234 switch is not used,
235 .B mhfixmsg
236 backs up the original the same way as
237 .BR rmm .
238 That is, it uses the
239 .I rmmproc
240 profile component, if present. If not present,
241 .B mhfixmsg
242 moves the original message to a backup file.
243 The
244 .B \-rmmproc
245 switch may be used to override this profile component. The
246 .B \-normmproc
247 switch disables the use of any
248 .I rmmproc
249 profile component and negates all prior
250 .B \-rmmproc
251 switches.
252 .PP
253 .SS "Integration with inc"
254 .B mhfixmsg
255 can be used as an add-hook, as described in %docdir%/README-HOOKS.
256 Note that add-hooks are called from all
257 .B nmh
258 programs that add a message to a folder, not just
259 .BR inc .
260 Alternatively, a simple shell alias or function can be used to
261 call
262 .B mhfixmsg
263 immediately after a successful invocation of
264 .BR inc .
265 For example, with bash:
266 .PP
267 .RS 5
268 alias inc='inc && mhfixmsg'
269 .RE
270 .PP
271 .SS "Integration with procmail"
272 By way of example, here is an excerpt from a procmailrc file
273 that filters messages through
274 .B mhfixmsg
275 before storing them in the user's
276 .I nmh-workers
277 folder. It also stores the incoming message in the
278 .I Backups
279 folder in a filename generated by
280 .BR mkstemp ,
281 which is a non-POSIX utility to generate a temporary file.
282 Alternatively,
283 .B mhfixmsg
284 could be called on the message after it is stored.
285 .PP
286 .RS 5
287 .nf
288 .ta \w'\-fixboundary 'u
289 PATH = %bindir%:$PATH
290 MAILDIR = `mhparam path`
291 #### The Backups directory is relative to MAILDIR.
292 MKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'
293 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
294 STORE = %nmhlibexecdir%/rcvstore
295
296 :0 w: nmh-workers/procmail.$LOCKEXT
297 * ^TOnmh-workers@nongnu.org
298 | tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers
299 .fi
300 .RE
301 .PP
302 .SH FILES
303 .B mhfixmsg
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
307 .I Mail
308 directory as specified in their profile. If not found there, the directory
309 .RI \*(lq %nmhetcdir% \*(rq
310 is checked.
311 .PP
312 .fc ^ ~
313 .nf
314 .ta \w'%nmhetcdir%/mhn.defaults 'u
315 ^$HOME/\&.mh\(ruprofile~^The user profile
316 ^%nmhetcdir%/mhn.defaults~^Default mhfixmsg conversion entries
317 .fi
318 .SH "PROFILE COMPONENTS"
319 .fc ^ ~
320 .nf
321 .ta 2.4i
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
326 .fi
327 .SH "SEE ALSO"
328 .IR inc (1),
329 .IR iconv (3),
330 .IR mh-profile (5),
331 .IR mhbuild (1),
332 .IR mhlist (1),
333 .IR mhparam (1),
334 .IR mhshow (1),
335 .IR mh-mkstemp (1),
336 .IR procmail (1),
337 .IR procmailrc (5),
338 .IR rcvstore (1),
339 .IR rmm (1)
340 .SH DEFAULTS
341 .nf
342 .RB ` +folder "' defaults to the current folder"
343 .RB ` msgs "' defaults to cur"
344 .RB ` "\-decodetext 8bit"'
345 .RB ` \-notextcharset '
346 .RB ` \-reformat '
347 .RB ` \-noreplacetextplain '
348 .RB ` \-fixboundary '
349 .RB ` \-fixcte '
350 .RB ` \-changecur '
351 .RB ` \-noverbose '
352 .fi
353 .SH CONTEXT
354 If a folder is given, it will become the current folder. The last
355 message selected from a folder will become the current message, unless
356 the
357 .B \-nochangecur
358 switch is enabled. If the
359 .B \-file
360 switch or an absolute pathname is used, the context will not be
361 modified.