Man pages: Replaced \*(lq and \*(rq with ` and '.
[mmh] / man / mhbuild.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH MHBUILD %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 mhbuild \- translate MIME composition draft
7 .SH SYNOPSIS
8 .na
9 .HP 5
10 .B mhbuild
11 .I file
12 .RB [ \-verbose " | " \-noverbose ]
13 .RB [ \-Version ]
14 .RB [ \-help ]
15 .ad
16 .SH DESCRIPTION
17 The
18 .B mhbuild
19 command will translate a MIME composition draft into
20 a valid MIME message.
21 .PP
22 .B mhbuild
23 creates multi-media messages as specified in RFC\-2045
24 thru RFC\-2049.  Currently
25 .B mhbuild
26 only supports encodings in
27 message bodies, and does not support the encoding of message headers as
28 specified in RFC\-2047.
29 .PP
30 If you specify the name of the composition file as `-',
31 then
32 .B mhbuild
33 will accept the composition draft on the standard
34 input.  If the translation of this input is successful,
35 .B mhbuild
36 will output the new MIME message to the standard output.  This argument
37 must be the last argument on the command line.
38 .PP
39 Otherwise if the file argument to
40 .B mhbuild
41 is the name of a valid
42 composition file, and the translation is successful,
43 .B mhbuild
44 will replace the original file with the new MIME message.  It will rename
45 the original file to start with the `,' character and end with the
46 string `.orig', e.g., if you are editing the file `draft',
47 it will be renamed to `,draft.orig'.  This allows you to easily
48 recover the
49 .B mhbuild
50 input file.
51 .SS "Translating the Composition File"
52 .B mhbuild
53 is essentially a filter to aid in the composition of MIME
54 messages.
55 .B mhbuild
56 will convert an
57 .B mhbuild
58 `composition file'
59 into a valid MIME message.  A
60 .B mhbuild
61 `composition file'
62 is just a file containing plain text that is interspersed
63 with various
64 .B mhbuild
65 directives.  When this file is processed
66 by
67 .BR mhbuild ,
68 the various directives will be expanded to the
69 appropriate content, and will be encoded according to the MIME standards.
70 The resulting MIME message can then be sent by electronic mail.
71 .PP
72 The formal syntax for a
73 .B mhbuild
74 composition file is defined at the
75 end of this document, but the ideas behind this format are not complex.
76 Basically, the body contains one or more contents.  A content consists of
77 either a directive, indicated with a `#' as the first character
78 of a line; or, plaintext (one or more lines of text).  The continuation
79 character, `\\`, may be used to enter a single directive on more
80 than one line, e.g.,
81 .PP
82 .RS 5
83 .nf
84 #image/png \\
85     /home/foobar/junk/picture.png
86 .fi
87 .RE
88 .PP
89 There are three kinds of directives:
90 `type',
91 `message' (#forw),
92 and `begin' (#begin).
93 .PP
94 .B "(1) The `type' directive
95 is used to directly specify the type and
96 subtype of a content.  You may only specify discrete types in this manner
97 (can't specify the types multipart or message with this directive).
98 You may optionally specify the name of a file containing the contents
99 in `native' (decoded) format.  If this filename starts with the
100 `|' character, then it represents a command to execute whose
101 output is captured accordingly.
102 For example,
103 .PP
104 .RS 5
105 .nf
106 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
107 .fi
108 .RE
109 .PP
110 If a filename is not given,
111 .B mhbuild
112 will look for information in the
113 user's profile to determine how the different contents should be composed.
114 This is accomplished by consulting a composition string, and executing
115 it under
116 .BR /bin/sh ,
117 with the standard output set to the content.
118 If the
119 .B \-verbose
120 switch is given,
121 .B mhbuild
122 will echo any commands that are used to create contents in this way.
123 .PP
124 The composition string may contain the following escapes:
125 .PP
126 .RS 5
127 .nf
128 .ta \w'%P  'u
129 %a      Insert parameters from directive
130 %f      Insert filename containing content
131 %F      %f, and stdout is not re-directed
132 %s      Insert content subtype
133 %%      Insert character %
134 .fi
135 .RE
136 .PP
137 First,
138 .B mhbuild
139 will look for an entry of the form:
140 .PP
141 .RS 5
142 mhbuild-compose-<type>/<subtype>
143 .RE
144 .PP
145 to determine the command to use to compose the content.  If this isn't
146 found,
147 .B mhbuild
148 will look for an entry of the form:
149 .PP
150 .RS 5
151 mhbuild-compose-<type>
152 .RE
153 .PP
154 to determine the composition command. If this isn't found,
155 .B mhbuild
156 will complain.
157 .PP
158 An example entry might be:
159 .PP
160 .RS 5
161 mhbuild-compose-audio/basic: record | raw2audio -F
162 .RE
163 .PP
164 Because commands like these will vary, depending on the display
165 environment used for login, composition strings for different
166 contents should probably be put in the file specified by the
167 .B $MHBUILD
168 environment variable, instead of directly in your
169 user profile.
170 .PP
171 .B "(2) The `message' directive (#forw)
172 is used to specify a message or
173 group of messages to include.  You may optionally specify the name of
174 the folder and which messages are to be forwarded.  If a folder is not
175 given, it defaults to the current folder.  Similarly, if a message is not
176 given, it defaults to the current message.  The message directive
177 is used by
178 .BR forw .
179 .PP
180 For example,
181 .PP
182 .RS 5
183 .nf
184 #forw +inbox 42 43 99
185 .fi
186 .RE
187 .PP
188 If you include a single message, it will be included directly as a content
189 of type `message/rfc822'.  If you include more than one message,
190 then
191 .B mhbuild
192 will add a content of type `multipart/digest'
193 and include each message as a subpart of this content.
194 .PP
195 .B "(3) The `begin' directive
196 is used to create a multipart content.
197 When using the `begin' directive, you must specify at least one
198 content between the begin and end pairs.
199 .PP
200 .RS 5
201 .nf
202 #begin
203 This will be a multipart with only one part.
204 #end
205 .fi
206 .RE
207 .PP
208 If you use multiple directives in a composition draft,
209 .B mhbuild
210 will
211 automatically encapsulate them inside a multipart content.  Therefore the
212 `begin' directive is only necessary if you wish to use nested
213 multiparts, or create a multipart message containing only one part.
214 .PP
215 For all of these directives, the user may include a brief description
216 of the content between the `[' character and the `]'
217 character.  This description will be copied into the
218 `Content-Description' header when the directive is processed.
219 .PP
220 .RS 5
221 .nf
222 #forw [important mail from Bob] +bob 1 2 3 4 5
223 .fi
224 .RE
225 .PP
226 Similarly, a disposition string may optionally be provided between
227 `{' and `}' characters; it will be copied into the
228 `Content-Disposition' header when the directive is processed.
229 If a disposition string is provided that does not contain a filename
230 parameter, and a filename is provided in the directive, it will be
231 added to the `Content-Disposition' header.  For example, the
232 following directive:
233 .PP
234 .RS 5
235 .nf
236 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
237 .fi
238 .RE
239 .PP
240 creates these message part headers:
241 .PP
242 .RS 5
243 .nf
244 Content-Type: text/plain; charset="iso-8859-1"
245 Content-Disposition: attachment; filename="summary.txt"
246 .fi
247 .RE
248 .PP
249 By default,
250 .B mhbuild
251 will generate a unique `Content-ID:' for each directive,
252 corresponding to each message part; however, the user may override
253 this by defining the ID using the `<' and `>'
254 characters.
255 .PP
256 In addition to the various directives, plaintext can be present.
257 Plaintext is gathered, until a directive is found or the draft is
258 exhausted, and this is made to form a text content.  If the plaintext
259 must contain a `#' at the beginning of a line, simply double it,
260 e.g.,
261 .PP
262 .RS 5
263 ##when sent, this line will start with only one #
264 .RE
265 .PP
266 If you want to end the plaintext prior to a directive, e.g., to have two
267 plaintext contents adjacent, simply insert a line containing a single
268 `#' character, e.g.,
269 .PP
270 .RS 5
271 .nf
272 this is the first content
273 #
274 and this is the second
275 .fi
276 .RE
277 .PP
278 Finally, if the plaintext starts with a line of the form:
279 .PP
280 .RS 5
281 Content-Description: text
282 .RE
283 .PP
284 then this will be used to describe the plaintext content.
285 You MUST follow this line with a blank line before starting
286 your text.
287 .PP
288 By default, plaintext is captured as a text/plain content.  You can
289 override this by starting the plaintext with `#<' followed by
290 a content-type specification.  For example, e.g.,
291 .PP
292 .RS 5
293 .nf
294 #<text/enriched
295 this content will be tagged as text/enriched
296 #
297 and this content will be tagged as text/plain
298 #
299 #<application/x-patch [this is a patch]
300 and this content will be tagged as application/x-patch
301 .fi
302 .RE
303 .PP
304 Note that if you use the `#<' plaintext-form, then the
305 content-description must be on the same line which identifies the content
306 type of the plaintext.
307 .PP
308 When composing a text content, you may indicate the relevant character
309 set by adding the `charset' parameter to the directive.
310 .PP
311 .RS 5
312 #<text/plain; charset=iso-8859-5
313 .RE
314 .PP
315 If a text content contains any 8\-bit characters (characters with the
316 high bit set) and the character set is not specified as above, then
317 .B mhbuild
318 will assume the character set is of the type given by the
319 environment variable MM_CHARSET.  If this environment variable is not
320 set, then the character set will be labeled as `x-unknown'.
321 .PP
322 If a text content contains only 7\-bit characters and the character set
323 is not specified as above, then the character set will be labeled as
324 `us-ascii'.
325 .PP
326 Putting this all together,
327 here is an example of a more complicated message draft.  The
328 following draft will expand into a multipart/mixed message
329 containing five parts:
330 .PP
331 .RS 5
332 .nf
333 To: nobody@nowhere.org
334 Cc:
335 Subject: Look and listen to me!
336 --------
337 The first part will be text/plain
338 #<text/enriched
339 The second part will be text/enriched
340 #
341 This third part will be text/plain
342 #audio/basic [silly giggle]  \\
343     |raw2audio -F < /usr/lib/sounds/giggle.au
344 #image/gif   [photo of foobar] \\
345                     /home/foobar/lib/picture.gif
346 .fi
347 .RE
348
349 .SS "Transfer Encodings"
350 After
351 .B mhbuild
352 constructs the new MIME message by parsing directives,
353 including files, etc., it scans the contents of the message to determine
354 which transfer encoding to use.  It will check for 8bit data, long lines,
355 spaces at the end of lines, and clashes with multipart boundaries.  It will
356 then choose a transfer encoding appropriate for each content type.
357
358 .SS "Invoking mhbuild"
359 Typically,
360 .B mhbuild
361 is invoked by the
362 .B send
363 program.
364 It expects an
365 .B mhbuild
366 composition file, which
367 .B send
368 will create, from the draft file, if MIME features are requested.
369 This is the case with attachment headers.
370 .PP
371 In contrast to previous versions, the user does not need to care
372 for any special actions anymore.
373
374 .SS "User Environment"
375 Because the environment in which
376 .B mhbuild
377 operates may vary for a
378 user,
379 .B mhbuild
380 will look for the environment variable
381 .BR $MHBUILD .
382 If present, this specifies the name of an additional user profile which
383 should be read.  Hence, when a user logs in on a particular machine,
384 this environment variable should be set to refer to a file containing
385 definitions useful for that machine.
386 .PP
387 Finally,
388 .B mhbuild
389 will attempt to consult a global
390 .B mhbuild
391 user profile, e.g.,
392 .PP
393 .RS 5
394 %etcdir%/mhn.defaults
395 .RE
396 .PP
397 if it exists.
398
399 .SS "Syntax of Composition Files"
400 The following is the formal syntax of a
401 .B mhbuild
402 `composition file'.
403 .PP
404 .RS 5
405 .nf
406 body         ::=     1*(content | EOL)
407
408 content      ::=     directive | plaintext
409
410 directive    ::=     "#" type "/" subtype
411                          0*(";" attribute "=" value)
412                          [ "(" comment ")" ]
413                          [ "<" id ">" ]
414                          [ "[" description "]" ]
415                          [ "{" disposition "}" ]
416                          [ filename ]
417                          EOL
418
419                    | "#forw"
420                          [ "<" id ">" ]
421                          [ "[" description "]" ]
422                          [ "{" disposition "}" ]
423                          [ "+"folder ] [ 0*msg ]
424                          EOL
425
426                    | "#begin"
427                            [ "<" id ">" ]
428                            [ "[" description "]" ]
429                            [ "{" disposition "}" ]
430                            [   "alternative"
431                              | "parallel"
432                              | something-else    ]
433                            EOL
434                          1*body
435                      "#end" EOL
436
437 plaintext    ::=     [ "Content-Description:"
438                            description EOL EOL ]
439                          1*line
440                      [ "#" EOL ]
441
442                    | "#<" type "/" subtype
443                          0*(";" attribute "=" value)
444                          [ "(" comment ")" ]
445                          [ "[" description "]" ]
446                          [ "{" disposition "}" ]
447                          EOL
448                          1*line
449                      [ "#" EOL ]
450
451 line         ::=     "##" text EOL
452                      -- interpreted as "#"text EOL
453                    | text EOL
454 .fi
455 .RE
456 .PP
457
458 .SH FILES
459 .fc ^ ~
460 .nf
461 .ta \w'%etcdir%/ExtraBigFileName  'u
462 ^$HOME/.mmh/profile~^The user profile
463 ^$MHBUILD~^Additional profile entries
464 ^%etcdir%/mhn.defaults~^System default MIME profile entries
465 .fi
466
467 .SH "PROFILE COMPONENTS"
468 .fc ^ ~
469 .nf
470 .ta 2.4i
471 .ta \w'ExtraBigProfileName  'u
472 ^Path:~^To determine the user's mail storage
473 ^Current\-Folder:~^To find the default current folder
474 ^mhbuild-compose-<type>*~^Template for composing contents
475 .fi
476
477 .SH "SEE ALSO"
478 mhlist(1), show(1), mhstore(1), forw(1),
479 .br
480 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
481 (RFC\-2045),
482 .br
483 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
484 (RFC\-2046),
485 .br
486 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
487 (RFC\-2047),
488 .br
489 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
490 (RFC\-2048),
491 .br
492 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
493 (RFC\-2049)
494
495 .SH DEFAULTS
496 .nf
497 .RB ` \-noverbose '
498 .fi
499
500 .SH CONTEXT
501 If a folder is given, it will become the current folder.  The last
502 message selected will become the current message.
503
504 .SH BUGS
505 Outlook 2002 won't display attachments that have a Content-ID header.
506 This is a bug in Outlook 2002, not in
507 .BR mhbuild .
508 To workaround it, invoke \fIe mhbuild\fP manually at the Whatnow prompt
509 and edit the draft again thereafter, removing the Content-ID headers.
510 Then send it.
511 There used to be a
512 .B \-nocontentid
513 switch to prevent Content-ID headers to be inserted, but as it was considerd
514 wrong to complicate all other MUAs instead of forcing the developers and users 
515 of broken MUAs to fix or change their software, it was removed.