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