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