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