updated ali-flist, with batch edit of others
[mmh] / man / mhbuild.man
1 .\"
2 .\" %nmhwarning%
3 .\" $Id$
4 .\"
5 .\" include the -mh macro file
6 .so %etcdir%/tmac.h
7 .\"
8 .TH MHBUILD %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
9 .SH NAME
10 mhbuild \- translate MIME composition draft
11 .SH SYNOPSIS
12 .in +.5i
13 .ti -.5i
14 mhbuild file
15 .br
16 \%[\-list] \%[-nolist]
17 \%[\-realsize] \%[\-norealsize]
18 .br
19 \%[\-headers] \%[\-noheaders]
20 \%[\-ebcdicsafe] \%[\-noebcdicsafe]
21 .br
22 \%[\-rfc934mode] \%[\-norfc934mode]
23 \%[\-verbose] \%[\-noverbose]
24 .br
25 \%[\-check] \%[\-nocheck]
26 \%[\-version]
27 \%[\-help]
28 .in -.5i
29 .SH DESCRIPTION
30 The \fImhbuild\fR command will translate a MIME composition draft into
31 a valid MIME message.
32
33 \fImhbuild\fR creates multi-media messages as specified in RFC\-2045
34 thru RFC\-2049.  Currently \fImhbuild\fR only supports encodings in
35 message bodies, and does not support the encoding of message headers as
36 specified in RFC\-2047.
37
38 If you specify the name of the composition file as \*(lq-\*(rq,
39 then \fImhbuild\fR will accept the composition draft on the standard
40 input.  If the translation of this input is successful, \fImhbuild\fR
41 will output the new MIME message to the standard output.  This argument
42 must be the last argument on the command line.
43
44 Otherwise if the file argument to \fImhbuild\fR is the name of a valid
45 composition file, and the translation is successful, \fImhbuild\fR will
46 replace the original file with the new MIME message.  It will rename
47 the original file to start with the \*(lq,\*(rq character and end with the
48 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
49 it will be renamed to \*(lq,draft.orig\*(rq.  This allows you to easily
50 recover the \fImhbuild\fR input file.
51
52 .Uh "Listing the Contents"
53 The `\-list' switch tells \fImhbuild\fR to list the table of contents
54 associated with the MIME message that is created.
55
56 The `\-headers' switch indicates
57 that a one-line banner should be displayed above the listing.  The
58 `\-realsize' switch tells \fImhbuild\fR to evaluate the \*(lqnative\*(rq
59 (decoded) format of each content prior to listing.  This provides an
60 accurate count at the expense of a small delay.  If the `\-verbose' switch
61 is present, then the listing will show any \*(lqextra\*(rq information
62 that is present in the message, such as comments in the Content-Type header.
63
64 .Uh "Translating the Composition File"
65 \fImhbuild\fR is essentially a filter to aid in the composition of MIME
66 messages.  \fImhbuild\fR will convert an
67 \fImhbuild\fR \*(lqcomposition file\*(rq
68 into a valid MIME message.  A \fImhbuild\fR \*(lqcomposition file\*(rq
69 is just a file containing plain text that is interspersed
70 with various \fImhbuild\fR directives.  When this file is processed
71 by \fImhbuild\fR, the various directives will be expanded to the
72 appropriate content, and will be encoded according to the MIME standards.
73 The resulting MIME message can then be sent by electronic mail.
74
75 The formal syntax for a \fImhbuild\fR composition file is defined at the
76 end of this document, but the ideas behind this format are not complex.
77 Basically, the body contains one or more contents.  A content consists of
78 either a directive, indicated with a \*(lq#\*(rq as the first character
79 of a line; or, plaintext (one or more lines of text).  The continuation
80 character, \*(lq\\\*(lq, may be used to enter a single directive on more
81 than one line, e.g.,
82 .sp
83 .nf
84 .in +.5i
85 #image/png \\
86     /home/foobar/junk/picture.png
87 .in -.5i
88 .fi
89 .sp
90 There are four kinds of directives: \*(lqtype\*(rq directives, which
91 name the type and subtype of the content; \*(lqexternal-type\*(rq
92 directives, which also name the type and subtype of the content; the
93 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
94 more messages; and, the \*(lqbegin\*(rq directive (#begin), which is
95 used to create a multipart content.
96
97 The \*(lqtype\*(rq directive is used to directly specify the type and
98 subtype of a content.  You may only specify discrete types in this manner
99 (can't specify the types multipart or message with this directive).
100 You may optionally specify the name of a file containing the contents
101 in \*(lqnative\*(rq (decoded) format.  If this filename starts with the
102 \*(lq|\*(rq character, then it represents a command to execute whose
103 output is captured accordingly.
104 For example,
105 .sp
106 .nf
107 .in +.5i
108 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
109 .in -.5i
110 .fi
111 .sp
112 If a filename is not given, \fImhbuild\fR 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 \fB/bin/sh\fR, with the standard output set to the content.
116 If the `\-verbose' switch is given, \fImhbuild\fR will echo any commands
117 that are used to create contents in this way.
118 .ne 13
119 The composition string may contain the following escapes:
120 .sp
121 .nf
122 .in +.5i
123 .ta \w'%P  'u
124 %a      Insert parameters from directive
125 %f      Insert filename containing content
126 %F      %f, and stdout is not re-directed
127 %s      Insert content subtype
128 %%      Insert character %
129 .re
130 .in -.5i
131 .fi
132 .sp
133
134 First,
135 \fImhbuild\fR will look for an entry of the form:
136 .sp
137 .in +.5i
138 mhbuild-compose-<type>/<subtype>
139 .in -.5i
140 .sp
141 to determine the command to use to compose the content.  If this isn't
142 found, \fImhbuild\fR will look for an entry of the form:
143 .sp
144 .in +.5i
145 mhbuild-compose-<type>
146 .in -.5i
147 .sp
148 to determine the composition command.
149
150 If this isn't found, \fImhbuild\fR
151 will complain.
152
153 An example entry might be:
154 .sp
155 .in +.5i
156 mhbuild-compose-audio/basic: record | raw2audio -F
157 .in -.5i
158 .sp
159 Because commands like these will vary, depending on the display
160 environment used for login, composition strings for different
161 contents should probably be put in the file specified by the
162 \fB$MHBUILD\fR environment variable, instead of directly in your
163 user profile.
164
165 The \*(lqexternal-type\*(rq directives are used to provide a MIME
166 reference to a content, rather than enclosing the contents itself
167 (for instance, by specifying an ftp site).  Hence, instead of
168 providing a filename as with the type directives, external-parameters
169 are supplied.  These look like regular parameters, so they must be
170 separated accordingly.  For example,
171 .sp
172 .nf
173 .in +.5i
174 #@application/octet-stream; \\
175     type=tar; \\
176     conversions=compress \\
177     [this is the nmh distribution] \\
178     name="nmh.tar.gz"; \\
179     directory="/pub/nmh"; \\
180     site="ftp.math.gatech.edu"; \\
181     access-type=anon-ftp; \\
182     mode="image"
183 .in -.5i
184 .fi
185 .sp
186 You must give a description string to separate the content parameters
187 from the external-parameters (although this string may be empty).
188 This description string is specified by enclosing it within
189 \*(lq[]\*(rq.
190 .ne 19
191 These parameters are of the form:
192 .sp
193 .nf
194 .in +.5i
195 .ta \w'access-type=  'u
196 access-type=    usually \fIanon-ftp\fR or \fImail-server\fR
197 name=   filename
198 permission=     read-only or read-write
199 site=   hostname
200 directory=      directoryname (optional)
201 mode=   usually \fIascii\fR or \fIimage\fR (optional)
202 size=   number of octets
203 server= mailbox
204 subject=        subject to send
205 body=   command to send for retrieval
206 .re
207 .in -.5i
208 .fi
209 .sp
210
211 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
212 group of messages to include.  You may optionally specify the name of
213 the folder and which messages are to be forwarded.  If a folder is not
214 given, it defaults to the current folder.  Similarly, if a message is not
215 given, it defaults to the current message.  Hence, the message directive
216 is similar to the \fIforw\fR\0(1) command, except that the former uses
217 the MIME rules for encapsulation rather than those specified in RFC\-934.
218 For example,
219 .sp
220 .nf
221 .in +.5i
222 #forw +inbox 42 43 99
223 .in -.5i
224 .fi
225 .sp
226 If you include a single message, it will be included directly as a content
227 of type \*(lqmessage/rfc822\*(rq.  If you include more than one message,
228 then \fImhbuild\fR will add a content of type \*(lqmultipart/digest\*(rq
229 and include each message as a subpart of this content.
230
231 If you are using this directive to include more than one message, you
232 may use the `\-rfc934mode' switch.  This switch will indicate that
233 \fImhbuild\fR should attempt to utilize the MIME encapsulation rules
234 in such a way that the \*(lqmultipart/digest\*(rq that is created
235 is (mostly) compatible with the encapsulation specified in RFC\-934.
236 If given, then RFC\-934 compliant user-agents should be able to burst the
237 message on reception\0--\0providing that the messages being encapsulated
238 do not contain encapsulated messages themselves.  The drawback of this
239 approach is that the encapsulations are generated by placing an extra
240 newline at the end of the body of each message.
241
242 The \*(lqbegin\*(rq directive is used to create a multipart content.
243 When using the \*(lqbegin\*(rq directive, you must specify at least one
244 content between the begin and end pairs.
245 .sp
246 .nf
247 .in +.5i
248 #begin
249 This will be a multipart with only one part.
250 #end
251 .in -.5i
252 .fi
253 .sp
254 If you use multiple directives in a composition draft, \fImhbuild\fR will
255 automatically encapsulate them inside a multipart content.  Therefore the
256 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
257 multiparts, or create a multipart message containing only one part.
258
259 For all of these directives, the user may include a brief description
260 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
261 character.  This description will be copied into the
262 \*(lqContent-Description\*(rq header when the directive is processed.
263 .sp
264 .nf
265 .in +.5i
266 #forw [important mail from Bob] +bob 1 2 3 4 5
267 .in -.5i
268 .fi
269 .sp
270 By default, \fImhbuild\fR will generate a unique \*(lqContent-ID:\*(rq for
271 each directive; however, the user may override this by defining the ID
272 using the \*(lq<\*(rq and \*(lq>\*(rq characters.
273
274 In addition to the various directives, plaintext can be present.
275 Plaintext is gathered, until a directive is found or the draft is
276 exhausted, and this is made to form a text content.  If the plaintext
277 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
278 .ne 6
279 e.g.,
280 .sp
281 .in +.5i
282 ##when sent, this line will start with only one #
283 .in -.5i
284 .sp
285 If you want to end the plaintext prior to a directive, e.g., to have two
286 plaintext contents adjacent, simply insert a line containing a single
287 \*(lq#\*(rq character,
288 .ne 10
289 e.g.,
290 .sp
291 .nf
292 .in +.5i
293 this is the first content
294 #
295 and this is the second
296 .in -.5i
297 .fi
298 .sp
299 Finally,
300 if the plaintext starts with a line of the form:
301 .sp
302 .in +.5i
303 Content-Description: text
304 .in -.5i
305 .sp
306 then this will be used to describe the plaintext content.
307 You MUST follow this line with a blank line before starting
308 your text.
309
310 By default, plaintext is captured as a text/plain content.  You can
311 override this by starting the plaintext with \*(lq#<\*(rq followed by
312 a content-type specification.  For example,
313 .ne 11
314 e.g.,
315 .sp
316 .nf
317 .in +.5i
318 #<text/enriched
319 this content will be tagged as text/enriched
320 #
321 and this content will be tagged as text/plain
322 #
323 #<application/x-patch [this is a patch]
324 and this content will be tagged as application/x-patch
325 .in -.5i
326 .fi
327 .sp
328 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
329 content-description must be on the same line which identifies the content
330 type of the plaintext.
331
332 When composing a text content, you may indicate the relevant character
333 set by adding the \*(lqcharset\*(rq parameter to the directive.
334 .sp
335 .in +.5i
336 #<text/plain; charset=iso-8859-5
337 .in -.5i
338 .sp
339 If a text content contains any 8bit characters (characters with the
340 high bit set) and the character set is not specified as above, then
341 \fImhbuild\fR will assume the character set is of the type given by the
342 environment variable MM_CHARSET.  If this environment variable is not
343 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
344
345 If a text content contains only 7bit characters and the character set
346 is not specified as above, then the character set will be labeled as
347 \*(lqus-ascii\*(rq
348
349 Putting this all together,
350 .ne 15
351 here is an example of a more complicated message draft.  The
352 following draft will expand into a multipart/mixed message
353 containing five parts:
354 .sp
355 .nf
356 .in +.5i
357 To: nobody@nowhere.org
358 cc:
359 Subject: Look and listen to me!
360 --------
361 The first part will be text/plain
362 #<text/enriched
363 The second part will be text/enriched
364 #
365 This third part will be text/plain
366 #audio/basic [silly giggle]  \\
367     |raw2audio -F < /usr/lib/sounds/giggle.au
368 #image/gif   [photo of foobar] \\
369                     /home/foobar/lib/picture.gif
370 .in -.5i
371 .fi
372 .sp
373 .Uh "Integrity Check"
374 If \fImhbuild\fR is given the `-check' switch, then it will also associate
375 an integrity check with each \*(lqleaf\*(rq content.  This will add a
376 Content-MD5 header field to the content, along with the md5 sum of the
377 unencoded contents.  This may be used by the receiver of the message to
378 verify that the contents of the message were not changed in transport.
379
380 .Uh "Transfer Encodings"
381 After \fImhbuild\fR constructs the new MIME message by parsing directives,
382 including files, etc., it scans the contents of the message to determine
383 which transfer encoding to use.  It will check for 8bit data, long lines,
384 spaces at the end of lines, and clashes with multipart boundaries.  It will
385 then choose a transfer encoding appropriate for each content type.
386
387 If an integrity check is being associated with each content by using
388 the `\-check' switch, then \fImhbuild\fR will encode each content with
389 a transfer encoding, even it the content contains only 7bit data.  This
390 is to increase the likelihood that the content is not changed while in
391 transport.
392
393 The switch `\-ebcdicsafe' will cause \fImhbuild\fR to slightly change
394 the way in which it performs the \*(lqquoted-printable\*(rq transfer
395 encoding.  Along with encoding 8bit characters, it will now also encode
396 certain common punctuation characters as well.  This slightly reduces the
397 readability of the message, but allows the message to pass more reliably
398 through mail gateways which involve the EBCDIC character encoding.
399
400 .Uh "Invoking mhbuild"
401 Typically, \fImhbuild\fR is invoked by the \fIwhatnow\fR program.  This
402 command will expect the body of the draft to be formatted as an
403 \fImhbuild\fR composition file.  Once you have composed this input file
404 using a command such as \fIcomp\fR, \fIrepl\fR, or \fIforw\fR, you invoke
405 \fImhbuild\fR at the \*(lqWhat now\*(rq prompt with
406 .sp
407 .in +.5i
408 What now? mime
409 .in -.5i
410 .sp
411 prior to sending the draft.  This will cause \fIwhatnow\fR to execute
412 \fImhbuild\fR to translate the composition file into MIME format.
413
414 It is also possible to have the \fIwhatnow\fR program invoke \fImhbuild\fR 
415 automatically when a message is sent.  To do this, you must add the line
416 .sp
417 .in +.5i
418 automimeproc: 1
419 .in -.5i
420 .sp
421 to your \&.mh\(ruprofile file.
422
423 Finally, you should consider adding this line to your profile:
424 .sp
425 .in +.5i
426 lproc: show
427 .in -.5i
428 .sp
429 This way, if you decide to \fBlist\fR after invoking \fImime\fR,
430 the command
431 .sp
432 .in +.5i
433 What now? list
434 .in -.5i
435 .sp
436 will work as you expect.
437
438 .Uh "User Environment"
439 Because the environment in which \fImhbuild\fR operates may vary for a
440 user, \fImhbuild\fR will look for the environment variable \fB$MHBUILD\fR.
441 If present, this specifies the name of an additional user profile which
442 should be read.  Hence, when a user logs in on a particular machine,
443 this environment variable should be set to refer to a file containing
444 definitions useful for that machine.
445
446 Finally, \fImhbuild\fR will attempt to consult a global \fImhbuild\fR
447 user profile,
448 .ne 6
449 e.g.,
450 .sp
451 .in +.5i
452 %etcdir%/mhn.defaults
453 .in -.5i
454 .sp
455 if it exists.
456
457 .Uh "Syntax of Composition Files"
458 .ne 59
459 The following is the formal syntax of a \fImhbuild\fR
460 \*(lqcomposition file\*(rq.
461 .sp
462 .nf
463 .in +.5i
464    body         ::=     1*(content | EOL)
465
466    content      ::=     directive | plaintext
467
468    directive    ::=     "#" type "/" subtype
469                             0*(";" attribute "=" value)
470                             [ "(" comment ")" ]
471                             [ "<" id ">" ]
472                             [ "[" description "]" ]
473                             [ filename ]
474                             EOL
475
476                       | "#@" type "/" subtype
477                             0*(";" attribute "=" value)
478                             [ "(" comment ")" ]
479                             [ "<" id ">" ]
480                             [ "[" description "]" ]
481                             external-parameters
482                             EOL
483
484                       | "#forw"
485                             [ "<" id ">" ]
486                             [ "[" description "]" ]
487                             [ "+"folder ] [ 0*msg ]
488                             EOL
489
490                       | "#begin"
491                               [ "<" id ">" ]
492                               [ "[" description "]" ]
493                               [   "alternative"
494                                 | "parallel"
495                                 | something-else    ]
496                               EOL
497                             1*body
498                         "#end" EOL
499
500    plaintext    ::=     [ "Content-Description:"
501                               description EOL EOL ]
502                             1*line
503                         [ "#" EOL ]
504
505                       | "#<" type "/" subtype
506                             0*(";" attribute "=" value)
507                             [ "(" comment ")" ]
508                             [ "[" description "]" ]
509                             EOL
510                             1*line
511                         [ "#" EOL ]
512
513    line         ::=     "##" text EOL
514                         -- interpreted as "#"text EOL
515                       | text EOL
516 .in -.5i
517 .fi
518 .sp
519 .Fi
520 ^$HOME/\&.mh\(ruprofile~^The user profile
521 ^$MHBUILD~^Additional profile entries
522 ^%etcdir%/mhn.defaults~^System default MIME profile entries
523 .Pr
524 ^Path:~^To determine the user's nmh directory
525 .Ps
526 ^Current\-Folder:~^To find the default current folder
527 .Ps
528 ^mhbuild-compose-<type>*~^Template for composing contents
529 .Sa
530 mhlist(1), mhshow(1), mhstore(1)
531 .br
532 RFC\-934:
533 .br
534    \fIProposed Standard for Message Encapsulation\fR,
535 .br
536 RFC\-2045:
537 .br
538    \fIMultipurpose Internet Mail Extensions (MIME) Part One:
539 .br
540    Format of Internet Message Bodies\fR,
541 .br
542 RFC\-2046:
543 .br
544    \fIMultipurpose Internet Mail Extensions (MIME) Part Two:
545 .br
546    Media Types\fR,
547 .br
548 RFC\-2047:
549 .br
550    \fIMultipurpose Internet Mail Extensions (MIME) Part Three:
551 .br
552    Message Header Extensions for Non-ASCII Text\fR,
553 .br
554 RFC\-2048:
555 .br
556    \fIMultipurpose Internet Mail Extensions (MIME) Part Four:
557 .br
558    Registration Procedures\fR,
559 .br
560 RFC\-2049:
561 .br
562    \fIMultipurpose Internet Mail Extensions (MIME) Part Five:
563 .br
564    Conformance Criteria and Examples\fR.
565 .De
566 `\-headers'
567 .Ds
568 `\-realsize'
569 .Ds
570 `\-norfc934mode'
571 .Ds
572 `\-nocheck'
573 .Ds
574 `\-noebcdicsafe'
575 .Ds
576 `\-noverbose'
577 .Co
578 If a folder is given, it will become the current folder.  The last
579 message selected will become the current message.
580 .En