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