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