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