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