Remove RCS keywords, since they no longer work after git migration.
[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 [ \-ebcdicsafe " | " \-noebcdicsafe ]
16 .RB [ \-rfc934mode " | " \-norfc934mode ]
17 .RB [ \-contentid " | " \-nocontentid ]
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     {application; filename="nmh.tar.gz"} \\
215     name="nmh.tar.gz"; \\
216     directory="/pub/nmh"; \\
217     site="ftp.math.gatech.edu"; \\
218     access-type=anon-ftp; \\
219     mode="image"
220 .fi
221 .RE
222 .PP
223 You must give a description string to separate the content parameters
224 from the external-parameters (although this string may be empty).
225 This description string is specified by enclosing it within
226 \*(lq[]\*(rq.  A disposition string, to appear in a
227 \*(lqContent-Disposition\*(rq header, may appear in the optional
228 \*(lq{}\*(rq.
229 .PP
230 These parameters are of the form:
231 .PP
232 .RS 5
233 .nf
234 .ta \w'access-type=  'u
235 access-type=    usually \fIanon-ftp\fR or \fImail-server\fR
236 name=   filename
237 permission=     read-only or read-write
238 site=   hostname
239 directory=      directoryname (optional)
240 mode=   usually \fIascii\fR or \fIimage\fR (optional)
241 size=   number of octets
242 server= mailbox
243 subject=        subject to send
244 body=   command to send for retrieval
245 .fi
246 .RE
247 .PP
248 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
249 group of messages to include.  You may optionally specify the name of
250 the folder and which messages are to be forwarded.  If a folder is not
251 given, it defaults to the current folder.  Similarly, if a message is not
252 given, it defaults to the current message.  Hence, the message directive
253 is similar to the
254 .B forw
255 command, except that the former uses
256 the MIME rules for encapsulation rather than those specified in RFC\-934.
257 For example,
258 .PP
259 .RS 5
260 .nf
261 #forw +inbox 42 43 99
262 .fi
263 .RE
264 .PP
265 If you include a single message, it will be included directly as a content
266 of type \*(lqmessage/rfc822\*(rq.  If you include more than one message,
267 then
268 .B mhbuild
269 will add a content of type \*(lqmultipart/digest\*(rq
270 and include each message as a subpart of this content.
271 .PP
272 If you are using this directive to include more than one message, you
273 may use the
274 .B \-rfc934mode
275 switch.  This switch will indicate that
276 .B mhbuild
277 should attempt to utilize the MIME encapsulation rules
278 in such a way that the \*(lqmultipart/digest\*(rq that is created
279 is (mostly) compatible with the encapsulation specified in RFC\-934.
280 If given, then RFC\-934 compliant user-agents should be able to burst the
281 message on reception\0--\0providing that the messages being encapsulated
282 do not contain encapsulated messages themselves.  The drawback of this
283 approach is that the encapsulations are generated by placing an extra
284 newline at the end of the body of each message.
285 .PP
286 The \*(lqbegin\*(rq directive is used to create a multipart content.
287 When using the \*(lqbegin\*(rq directive, you must specify at least one
288 content between the begin and end pairs.
289 .PP
290 .RS 5
291 .nf
292 #begin
293 This will be a multipart with only one part.
294 #end
295 .fi
296 .RE
297 .PP
298 If you use multiple directives in a composition draft,
299 .B mhbuild
300 will
301 automatically encapsulate them inside a multipart content.  Therefore the
302 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
303 multiparts, or create a multipart message containing only one part.
304 .PP
305 For all of these directives, the user may include a brief description
306 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
307 character.  This description will be copied into the
308 \*(lqContent-Description\*(rq header when the directive is processed.
309 .PP
310 .RS 5
311 .nf
312 #forw [important mail from Bob] +bob 1 2 3 4 5
313 .fi
314 .RE
315 .PP
316 Similarly, a disposition string may optionally be provided between
317 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
318 \*(lqContent-Disposition\*(rq header when the directive is processed.
319 If a disposition string is provided that does not contain a filename
320 parameter, and a filename is provided in the directive, it will be
321 added to the \*(lqContent-Disposition\*(rq header.  For example, the
322 following directive:
323 .PP
324 .RS 5
325 .nf
326 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
327 .fi
328 .RE
329 .PP
330 creates these message part headers:
331 .PP
332 .RS 5
333 .nf
334 Content-Type: text/plain; charset="iso-8859-1"
335 Content-Disposition: attachment; filename="summary.txt"
336 .fi
337 .RE
338 .PP
339 By default,
340 .B mhbuild
341 will generate a unique \*(lqContent-ID:\*(rq for each directive,
342 corresponding to each message part; however, the user may override
343 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
344 characters.  The
345 .B \-nocontentid
346 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
347 even in the top level of the message.
348 .PP
349 In addition to the various directives, plaintext can be present.
350 Plaintext is gathered, until a directive is found or the draft is
351 exhausted, and this is made to form a text content.  If the plaintext
352 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
353 e.g.,
354 .PP
355 .RS 5
356 ##when sent, this line will start with only one #
357 .RE
358 .PP
359 If you want to end the plaintext prior to a directive, e.g., to have two
360 plaintext contents adjacent, simply insert a line containing a single
361 \*(lq#\*(rq character, e.g.,
362 .PP
363 .RS 5
364 .nf
365 this is the first content
366 #
367 and this is the second
368 .fi
369 .RE
370 .PP
371 Finally, if the plaintext starts with a line of the form:
372 .PP
373 .RS 5
374 Content-Description: text
375 .RE
376 .PP
377 then this will be used to describe the plaintext content.
378 You MUST follow this line with a blank line before starting
379 your text.
380 .PP
381 By default, plaintext is captured as a text/plain content.  You can
382 override this by starting the plaintext with \*(lq#<\*(rq followed by
383 a content-type specification.  For example, e.g.,
384 .PP
385 .RS 5
386 .nf
387 #<text/enriched
388 this content will be tagged as text/enriched
389 #
390 and this content will be tagged as text/plain
391 #
392 #<application/x-patch [this is a patch]
393 and this content will be tagged as application/x-patch
394 .fi
395 .RE
396 .PP
397 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
398 content-description must be on the same line which identifies the content
399 type of the plaintext.
400 .PP
401 When composing a text content, you may indicate the relevant character
402 set by adding the \*(lqcharset\*(rq parameter to the directive.
403 .PP
404 .RS 5
405 #<text/plain; charset=iso-8859-5
406 .RE
407 .PP
408 If a text content contains any 8\-bit characters (characters with the
409 high bit set) and the character set is not specified as above, then
410 .B mhbuild
411 will assume the character set is of the type given by the
412 environment variable MM_CHARSET.  If this environment variable is not
413 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
414 .PP
415 If a text content contains only 7\-bit characters and the character set
416 is not specified as above, then the character set will be labeled as
417 \*(lqus-ascii\*(rq.
418 .PP
419 Putting this all together,
420 here is an example of a more complicated message draft.  The
421 following draft will expand into a multipart/mixed message
422 containing five parts:
423 .PP
424 .RS 5
425 .nf
426 To: nobody@nowhere.org
427 cc:
428 Subject: Look and listen to me!
429 --------
430 The first part will be text/plain
431 #<text/enriched
432 The second part will be text/enriched
433 #
434 This third part will be text/plain
435 #audio/basic [silly giggle]  \\
436     |raw2audio -F < /usr/lib/sounds/giggle.au
437 #image/gif   [photo of foobar] \\
438                     /home/foobar/lib/picture.gif
439 .fi
440 .RE
441 .SS "Integrity Check"
442 If
443 .B mhbuild
444 is given the
445 .B \-check
446 switch, then it will also associate
447 an integrity check with each \*(lqleaf\*(rq content.  This will add a
448 Content-MD5 header field to the content, along with the md5 sum of the
449 unencoded contents.  This may be used by the receiver of the message to
450 verify that the contents of the message were not changed in transport.
451
452 .SS "Transfer Encodings"
453 After
454 .B mhbuild
455 constructs the new MIME message by parsing directives,
456 including files, etc., it scans the contents of the message to determine
457 which transfer encoding to use.  It will check for 8bit data, long lines,
458 spaces at the end of lines, and clashes with multipart boundaries.  It will
459 then choose a transfer encoding appropriate for each content type.
460 .PP
461 If an integrity check is being associated with each content by using
462 the
463 .B \-check
464 switch, then
465 .B mhbuild
466 will encode each content with
467 a transfer encoding, even it the content contains only 7\-bit data.  This
468 is to increase the likelihood that the content is not changed while in
469 transport.
470 .PP
471 The switch
472 .B \-ebcdicsafe
473 will cause
474 .B mhbuild
475 to slightly change
476 the way in which it performs the \*(lqquoted-printable\*(rq transfer
477 encoding.  Along with encoding 8\-bit characters, it will now also encode
478 certain common punctuation characters as well.  This slightly reduces the
479 readability of the message, but allows the message to pass more reliably
480 through mail gateways which involve the EBCDIC character encoding.
481
482 .SS "Invoking mhbuild"
483 Typically,
484 .B mhbuild
485  is invoked by the
486 .B whatnow
487 program.  This
488 command will expect the body of the draft to be formatted as an
489 .B mhbuild
490 composition file.  Once you have composed this input file
491 using a command such as
492 .BR comp ,
493 .BR repl ,
494 or
495 .BR forw ,
496 you invoke
497 .B mhbuild
498 at the \*(lqWhat now\*(rq prompt with
499 .PP
500 .RS 5
501 What now? mime
502 .RE
503 .PP
504 prior to sending the draft.  This will cause
505 .B whatnow
506 to execute
507 .B mhbuild
508 to translate the composition file into MIME format.
509 .PP
510 It is also possible to have the
511 .B whatnow
512 program invoke
513 .B mhbuild
514 automatically when a message is sent.  To do this, you must add the line
515 .PP
516 .RS 5
517 automimeproc: 1
518 .RE
519 .PP
520 to your
521 .I \&.mh\(ruprofile
522 file.
523 .PP
524 Finally, you should consider adding this line to your profile:
525 .PP
526 .RS 5
527 lproc: show
528 .RE
529 .PP
530 This way, if you decide to
531 .B list
532 after invoking
533 .BR mime ,
534 the command
535 .PP
536 .RS 5
537 What now? list
538 .RE
539 .PP
540 will work as you expect.
541
542 .SS "User Environment"
543 Because the environment in which
544 .B mhbuild
545 operates may vary for a
546 user,
547 .B mhbuild
548 will look for the environment variable
549 .BR $MHBUILD .
550 If present, this specifies the name of an additional user profile which
551 should be read.  Hence, when a user logs in on a particular machine,
552 this environment variable should be set to refer to a file containing
553 definitions useful for that machine.
554 .PP
555 Finally,
556 .B mhbuild
557 will attempt to consult a global
558 .B mhbuild
559 user profile, e.g.,
560 .PP
561 .RS 5
562 %etcdir%/mhn.defaults
563 .RE
564 .PP
565 if it exists.
566
567 .SS "Syntax of Composition Files"
568 The following is the formal syntax of a
569 .B mhbuild
570 \*(lqcomposition file\*(rq.
571 .PP
572 .RS 5
573 .nf
574 body         ::=     1*(content | EOL)
575
576 content      ::=     directive | plaintext
577
578 directive    ::=     "#" type "/" subtype
579                          0*(";" attribute "=" value)
580                          [ "(" comment ")" ]
581                          [ "<" id ">" ]
582                          [ "[" description "]" ]
583                          [ "{" disposition "}" ]
584                          [ filename ]
585                          EOL
586
587                    | "#@" type "/" subtype
588                          0*(";" attribute "=" value)
589                          [ "(" comment ")" ]
590                          [ "<" id ">" ]
591                          [ "[" description "]" ]
592                          [ "{" disposition "}" ]
593                          external-parameters
594                          EOL
595
596                    | "#forw"
597                          [ "<" id ">" ]
598                          [ "[" description "]" ]
599                          [ "{" disposition "}" ]
600                          [ "+"folder ] [ 0*msg ]
601                          EOL
602
603                    | "#begin"
604                            [ "<" id ">" ]
605                            [ "[" description "]" ]
606                            [ "{" disposition "}" ]
607                            [   "alternative"
608                              | "parallel"
609                              | something-else    ]
610                            EOL
611                          1*body
612                      "#end" EOL
613
614 plaintext    ::=     [ "Content-Description:"
615                            description EOL EOL ]
616                          1*line
617                      [ "#" EOL ]
618
619                    | "#<" type "/" subtype
620                          0*(";" attribute "=" value)
621                          [ "(" comment ")" ]
622                          [ "[" description "]" ]
623                          [ "{" disposition "}" ]
624                          EOL
625                          1*line
626                      [ "#" EOL ]
627
628 line         ::=     "##" text EOL
629                      -- interpreted as "#"text EOL
630                    | text EOL
631 .fi
632 .RE
633 .PP
634
635 .SH FILES
636 .fc ^ ~
637 .nf
638 .ta \w'%etcdir%/ExtraBigFileName  'u
639 ^$HOME/\&.mh\(ruprofile~^The user profile
640 ^$MHBUILD~^Additional profile entries
641 ^%etcdir%/mhn.defaults~^System default MIME profile entries
642 .fi
643
644 .SH "PROFILE COMPONENTS"
645 .fc ^ ~
646 .nf
647 .ta 2.4i
648 .ta \w'ExtraBigProfileName  'u
649 ^Path:~^To determine the user's nmh directory
650 ^Current\-Folder:~^To find the default current folder
651 ^mhbuild-compose-<type>*~^Template for composing contents
652 .fi
653
654 .SH "SEE ALSO"
655 mhlist(1), mhshow(1), mhstore(1),
656 .br
657 .I "Proposed Standard for Message Encapsulation"
658 (RFC\-934),
659 .br
660 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
661 (RFC\-2045),
662 .br
663 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
664 (RFC\-2046),
665 .br
666 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
667 (RFC\-2047),
668 .br
669 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
670 (RFC\-2048),
671 .br
672 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
673 (RFC\-2049)
674
675 .SH DEFAULTS
676 .nf
677 .RB ` \-headers '
678 .RB ` \-realsize '
679 .RB ` \-norfc934mode '
680 .RB ` \-contentid '
681 .RB ` \-nocheck '
682 .RB ` \-noebcdicsafe '
683 .RB ` \-noverbose '
684 .fi
685
686 .SH CONTEXT
687 If a folder is given, it will become the current folder.  The last
688 message selected will become the current message.