]> diplodocus.org Git - nmh/blob - man/mhfixmsg.man
Fix up the unquote test, with help from Lyndon and Ralph.
[nmh] / man / mhfixmsg.man
1 .TH MHFIXMSG %manext1% "May 4, 2013" "%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 .RB [ \-decodetext
14 8bit/7bit |
15 .BR \-nodecodetext ]
16 .RB [ \-textcodeset
17 .I codeset
18 .RB "| " \-notextcodeset ]
19 .RB [ \-reformat " | " \-noreformat ]
20 .RB [ \-replacetextplain " | " \-noreplacetextplain ]
21 .RB [ \-fixboundary " | " \-nofixboundary ]
22 .RB [ \-fixcte " | " \-nofixcte ]
23 .RB [ \-file
24 .IR file ]
25 .RB [ \-outfile
26 .IR outfile ]
27 .RB [ \-rmmproc
28 .IR program ]
29 .RB [ \-normmproc ]
30 .RB [ \-verbose " | " \-noverbose ]
31 .RB [ \-version ]
32 .RB [ \-help ]
33 .ad
34 .SH DESCRIPTION
35 .B mhfixmsg
36 rewrites MIME messages, applying specific transformations such as
37 decoding of MIME-encoded message parts and repairing invalid MIME
38 headers.
39 .PP
40 MIME messages are specified in RFC 2045 to RFC 2049
41 (see
42 .IR mhbuild (1)).
43 The
44 .B mhlist
45 command is invaluable for viewing the content structure of MIME
46 messages.
47 .B mhfixmsg
48 passes non-MIME messages through without any transformations. If no
49 transformations apply to a MIME message, the original message or file
50 is not modified or removed.
51 .PP
52 The
53 .B \-decodetext
54 switch enables a transformation to decode each base64 and
55 quoted-printable text message part to the selected 8bit or 7bit
56 encoding. If 7bit is selected for a base64 part but it will only fit
57 8bit, as defined by RFC 2045, then it will be decoded to 8bit
58 quoted-printable. Otherwise, if the decoded text would not fit the
59 selected encoding, the part is not decoded (and a message will be
60 displayed if
61 .B \-verbose
62 is enabled).
63 .PP
64 When the
65 .B \-decodetext
66 switch is enabled, each carriage return character that precedes a
67 linefeed character is removed from text parts encoded in ASCII,
68 ISO-8859-x, UTF-8, or Windows-12xx.
69 .PP
70 The
71 .B \-textcodeset
72 switch specifies that all text/plain parts of the message(s)
73 should be converted to
74 .IR codeset .
75 Codeset conversions require that
76 .B nmh
77 be built with
78 .IR iconv (3).
79 To convert text parts other than text/plain, an external program can
80 be used, via the
81 .B \-reformat
82 switch.
83 .PP
84 The
85 .B \-reformat
86 switch enables a transformation for text parts in the message. For
87 each text part that is not text/plain and that does not have a
88 corresponding text/plain in a multipart/alternative part,
89 .B mhfixmsg
90 looks for a mhfixmsg-format-text/subtype profile entry that matches
91 the subtype of the part. If one is found and can be used to
92 successfully convert the part to text/plain,
93 .B mhfixmsg
94 inserts that text/plain part at the beginning of the containing
95 multipart/alternative part, if present. If not, it creates a
96 multipart/alternative part.
97 .PP
98 The
99 .B \-replacetextplain
100 switch broadens the applicability of
101 .B \-reformat
102 by always replacing a corresponding text/plain part, if one exists.
103 If
104 .B \-verbose
105 if enabled, the replacement will be shown as two steps: a removal of
106 the text/plain part followed by the usual insertion of a new part.
107 .PP
108 .B \-reformat
109 requires a profile entry for each text part subtype to be reformatted.
110 The mhfixmsg-format-text/subtype profile entries are based on external
111 conversion programs, and are used the same way that
112 .B mhshow
113 uses its mhshow-show-text/subtype entries. When
114 .B nmh
115 is installed, it searches for a conversion program for text/html
116 content, and if one is found, inserts a mhfixmsg-format-text/html
117 entry in %etcdir%/mhn.defaults. An entry of the same name in the
118 user's profile takes precedence. The user can add entries for
119 other text subtypes to their profile.
120 .PP
121 The
122 .B \-fixboundary
123 switch enables a transformation to repair the boundary portion of the
124 Content-Type header field of the message to match the boundaries of
125 the outermost multipart part of the message, if it does not. That
126 condition is indicated by a \*(lqbogus multipart content in
127 message\*(rq error message from
128 .B mhlist
129 and other
130 .B nmh
131 programs that parse MIME messages.
132 .PP
133 The
134 .B \-fixcte
135 switch enables a transformation to change the
136 Content-Transfer-Encoding from an invalid value to 8bit in message
137 parts with a Content-Type of multipart, as required by RFC 2045,
138 Section 6.4. That condition is indicated by a \*(lqmust be encoded in
139 7bit, 8bit, or binary\*(rq error message from
140 .B mhlist
141 and other
142 .B nmh
143 programs that parse MIME messages.
144 .PP
145 The
146 .B \-verbose
147 switch directs
148 .B mhfixmsg
149 to output informational message for each transformation applied.
150 .PP
151 The
152 .B \-file
153 .I file
154 switch directs
155 .B mhfixmsg
156 to use the specified
157 file as the source message, rather than a message from a folder.
158 If this file is \*(lq-\*(rq, then
159 .B mhfixmsg
160 accepts the source message on the standard input stream. If
161 the
162 .B \-outfile
163 switch is not enabled when using the standard input stream,
164 .B mhfixmsg
165 will not produce a transformed output message.
166 .PP
167 .BR mhfixmsg ,
168 by default, transforms the message in place. If the
169 .B \-outfile
170 switch is enabled, then
171 .B mhfixmsg
172 does not modify the input message or file, but instead places its
173 output in the specified file. An outfile name of \*(lq-\*(rq
174 specifies the standard output stream.
175 .PP
176 Combined with the
177 .B \-verbose
178 switch, the
179 .B \-outfile
180 switch can be used to show what transformations
181 .B mhfixmsg
182 would apply without actually applying them, e.g.,
183 .PP
184 .RS 5
185 mhfixmsg -outfile /dev/null -verbose
186 .RE
187 .PP
188 As always, this usage obeys any
189 .B mhfixmsg
190 switches in the user's profile.
191 .PP
192 .B \-outfile
193 can be combined with
194 .B rcvstore
195 to add a single transformed message to a different folder, e.g.,
196 .PP
197 .RS 5
198 mhfixmsg -outfile - | \\
199 .RS 0
200 %libdir%/rcvstore +folder
201 .RE
202 .RE
203 .SS Summary of Applicability
204 The transformations apply to the parts of a message depending on
205 content type and/or encoding as follows:
206 .PP
207 .RS 5
208 .nf
209 .ta \w'\-fixboundary 'u
210 \-decodetext base64 and quoted-printable encoded text parts
211 \-textcodeset text/plain parts
212 \-reformat text parts that are not text/plain
213 \-fixboundary outermost multipart part
214 \-fixcte multipart part
215 .fi
216 .RE
217 .PP
218 .SS "Backup of Original Message/File"
219 If it applies any transformations to a message or file,
220 and the
221 .B \-outfile
222 switch is not used,
223 .B mhfixmsg
224 backs up the original the same way as
225 .BR rmm .
226 That is, it uses the
227 .I rmmproc
228 profile component, if present. If not present,
229 .B mhfixmsg
230 moves the original message to a backup file.
231 The
232 .B \-rmmproc
233 switch may be used to override this profile component. The
234 .B \-normmproc
235 switch disables the use of any
236 .I rmmproc
237 profile component and negates all prior
238 .B \-rmmproc
239 switches.
240 .PP
241 .SS "Integration with procmail"
242 By way of example, here is an excerpt from a procmailrc file
243 that filters messages through
244 .B mhfixmsg
245 before storing them in the user's
246 .I nmh-workers
247 folder. It also stores the incoming message in the
248 .I Backups
249 folder in a filename generated by
250 .BR mktemp ,
251 which is a non-POSIX utility to generate a temporary file.
252 If you do not have that utility, then the
253 .BR mkstemp (3)
254 function could form the basis for a substitute. Or,
255 .B mhfixmsg
256 could be called on the message after it is stored.
257 .PP
258 .RS 5
259 .nf
260 .ta \w'\-fixboundary 'u
261 PATH = %bindir%:$PATH
262 MAILDIR = `mhparam path`
263 MKTEMP = 'mktemp Backups/mhfixmsg.XXXXXXXX'
264 MHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'
265 STORE = %libdir%/rcvstore
266
267 :0 w: nmh-worker/procmail.$LOCKEXT
268 * ^TOnmh-workers@nongnu.org
269 | tee `$MKTEMP` | $MHFIXMSG | $STORE +nmh-workers
270 .fi
271 .RE
272 .PP
273 .SH FILES
274 .B mhfixmsg
275 looks for mhn.defaults in multiple locations: absolute pathnames are
276 accessed directly, tilde expansion is done on usernames, and files are
277 searched for in the user's
278 .I Mail
279 directory as specified in their profile. If not found there, the directory
280 .RI \*(lq %etcdir% \*(rq
281 is checked.
282 .PP
283 .fc ^ ~
284 .nf
285 .ta \w'%etcdir%/mhn.defaults 'u
286 ^$HOME/\&.mh\(ruprofile~^The user profile
287 ^%etcdir%/mhn.defaults~^Default mhfixmsg conversion entries
288 .fi
289 .SH "PROFILE COMPONENTS"
290 .fc ^ ~
291 .nf
292 .ta 2.4i
293 .ta \w'ExtraBigProfileName 'u
294 ^Path:~^To determine the user's nmh directory
295 ^Current\-Folder:~^To find the default current folder
296 ^rmmproc:~^Program to delete original messages or files
297 .fi
298 .SH "SEE ALSO"
299 .IR mh-profile (5),
300 .IR mhbuild (1),
301 .IR mhlist (1),
302 .IR mhshow (1),
303 .IR mkstemp (3),
304 .IR procmail (1),
305 .IR procmailrc (5),
306 .IR rcvstore (1),
307 .IR rmm (1)
308 .SH DEFAULTS
309 .nf
310 .RB ` +folder "' defaults to the current folder"
311 .RB ` msgs "' defaults to cur"
312 .RB ` "\-decodetext 8bit"'
313 .RB ` \-notextcodeset '
314 .RB ` \-reformat '
315 .RB ` \-noreplacetextplain '
316 .RB ` \-fixboundary '
317 .RB ` \-fixcte '
318 .RB ` \-noverbose '
319 .fi
320 .SH CONTEXT
321 If a folder is given, it will become the current folder. The last
322 message selected from a folder will become the current message. If
323 the
324 .B \-file
325 switch is used, the context will not be modified.