]> diplodocus.org Git - nmh/blob - man/mhfixmsg.man
Fix test for inlineonly.
[nmh] / man / mhfixmsg.man
1 .TH MHFIXMSG %manext1% "March 16, 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 [ \-verbose " | " \-noverbose ]
32 .RB [ \-version ]
33 .RB [ \-help ]
34 .ad
35 .SH DESCRIPTION
36 .B mhfixmsg
37 rewrites MIME messages, applying specific transformations such as
38 decoding of MIME-encoded message parts and repairing invalid MIME
39 headers.
40 .PP
41 MIME messages are specified in RFC 2045 to RFC 2049
42 (see
43 .IR mhbuild (1)).
44 The
45 .B mhlist
46 command is invaluable for viewing the content structure of MIME
47 messages.
48 .B mhfixmsg
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.
52 .PP
53 The
54 .B \-decodetext
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
61 displayed if
62 .B \-verbose
63 is enabled).
64 .PP
65 When the
66 .B \-decodetext
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.
70 .PP
71 The
72 .B \-textcharset
73 switch specifies that all text/plain parts of the message(s)
74 should be converted to
75 .IR charset .
76 Charset conversions require that
77 .B nmh
78 be built with
79 .IR iconv (3);
80 see the
81 .BR mhparam (1)
82 man page for how determine whether your
83 .B nmh
84 installation includes that.
85 To convert text parts other than text/plain, an external program can
86 be used, via the
87 .B \-reformat
88 switch.
89 .PP
90 The
91 .B \-reformat
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,
95 .B mhfixmsg
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,
99 .B mhfixmsg
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.
103 .PP
104 The
105 .B \-replacetextplain
106 switch broadens the applicability of
107 .B \-reformat
108 by always replacing a corresponding text/plain part, if one exists.
109 If
110 .B \-verbose
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.
113 .PP
114 .B \-reformat
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
118 .B mhshow
119 uses its mhshow-show-text/subtype entries. When
120 .B nmh
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.
126 .PP
127 The
128 .B \-fixboundary
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
134 .B mhlist
135 and other
136 .B nmh
137 programs that parse MIME messages.
138 .PP
139 The
140 .B \-fixcte
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
146 .B mhlist
147 and other
148 .B nmh
149 programs that parse MIME messages.
150 .PP
151 The
152 .B \-verbose
153 switch directs
154 .B mhfixmsg
155 to output informational message for each transformation applied.
156 .PP
157 The
158 .B \-file
159 .I file
160 switch directs
161 .B mhfixmsg
162 to use the specified
163 file as the source message, rather than a message from a folder.
164 Only one file argument may be provided. The
165 .B \-file
166 switch is implied if
167 .I file
168 is an absolute pathname.
169 If the file is \*(lq-\*(rq, then
170 .B mhfixmsg
171 accepts the source message on the standard input stream. If
172 the
173 .B \-outfile
174 switch is not enabled when using the standard input stream,
175 .B mhfixmsg
176 will not produce a transformed output message.
177 .PP
178 .BR mhfixmsg ,
179 by default, transforms the message in place. If the
180 .B \-outfile
181 switch is enabled, then
182 .B mhfixmsg
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.
186 .PP
187 Combined with the
188 .B \-verbose
189 switch, the
190 .B \-outfile
191 switch can be used to show what transformations
192 .B mhfixmsg
193 would apply without actually applying them, e.g.,
194 .PP
195 .RS 5
196 mhfixmsg -outfile /dev/null -verbose
197 .RE
198 .PP
199 As always, this usage obeys any
200 .B mhfixmsg
201 switches in the user's profile.
202 .PP
203 .B \-outfile
204 can be combined with
205 .B rcvstore
206 to add a single transformed message to a different folder, e.g.,
207 .PP
208 .RS 5
209 mhfixmsg -outfile - | \\
210 .RS 0
211 %libdir%/rcvstore +folder
212 .RE
213 .RE
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:
217 .PP
218 .RS 5
219 .nf
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
226 .fi
227 .RE
228 .PP
229 .SS "Backup of Original Message/File"
230 If it applies any transformations to a message or file,
231 and the
232 .B \-outfile
233 switch is not used,
234 .B mhfixmsg
235 backs up the original the same way as
236 .BR rmm .
237 That is, it uses the
238 .I rmmproc
239 profile component, if present. If not present,
240 .B mhfixmsg
241 moves the original message to a backup file.
242 The
243 .B \-rmmproc
244 switch may be used to override this profile component. The
245 .B \-normmproc
246 switch disables the use of any
247 .I rmmproc
248 profile component and negates all prior
249 .B \-rmmproc
250 switches.
251 .PP
252 .SS "Integration with inc"
253 .B mhfixmsg
254 can be used as an add-hook, as described in %docdir%/README-HOOKS.
255 Note that add-hooks are called from all
256 .B nmh
257 programs that add a message to a folder, not just
258 .BR inc .
259 Alternatively, a simple shell alias or function can be used to
260 call
261 .B mhfixmsg
262 immediately after a successful invocation of
263 .BR inc .
264 For example, with bash:
265 .PP
266 .RS 5
267 alias inc='inc && mhfixmsg'
268 .RE
269 .PP
270 .SS "Integration with procmail"
271 By way of example, here is an excerpt from a procmailrc file
272 that filters messages through
273 .B mhfixmsg
274 before storing them in the user's
275 .I nmh-workers
276 folder. It also stores the incoming message in the
277 .I Backups
278 folder in a filename generated by
279 .BR mktemp ,
280 which is a non-POSIX utility to generate a temporary file.
281 If you do not have that utility, then the
282 .BR mkstemp (3)
283 function could form the basis for a substitute. Or,
284 .B mhfixmsg
285 could be called on the message after it is stored.
286 .PP
287 .RS 5
288 .nf
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
295
296 :0 w: nmh-worker/procmail.$LOCKEXT
297 * ^TOnmh-workers@nongnu.org
298 | tee `$MKTEMP` | $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 %etcdir% \*(rq
310 is checked.
311 .PP
312 .fc ^ ~
313 .nf
314 .ta \w'%etcdir%/mhn.defaults 'u
315 ^$HOME/\&.mh\(ruprofile~^The user profile
316 ^%etcdir%/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 mkstemp (3),
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 ` \-noverbose '
351 .fi
352 .SH CONTEXT
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
355 the
356 .B \-file
357 switch or an absolute pathname is used, the context will not be
358 modified.