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