babc1b2c166a13ee1e2257f75e0988c9fef30913
[mmh] / man / mhbuild.man1
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 [ \-version ]
20 .RB [ \-help ]
21 .ad
22 .SH DESCRIPTION
23 The
24 .B mhbuild
25 command will translate a MIME composition draft into
26 a valid MIME message.
27 .PP
28 .B mhbuild
29 creates multi-media messages as specified in RFC\-2045
30 thru RFC\-2049.  Currently
31 .B mhbuild
32 only supports encodings in
33 message bodies, and does not support the encoding of message headers as
34 specified in RFC\-2047.
35 .PP
36 If you specify the name of the composition file as \*(lq-\*(rq,
37 then
38 .B mhbuild
39 will accept the composition draft on the standard
40 input.  If the translation of this input is successful,
41 .B mhbuild
42 will output the new MIME message to the standard output.  This argument
43 must be the last argument on the command line.
44 .PP
45 Otherwise if the file argument to
46 .B mhbuild
47 is the name of a valid
48 composition file, and the translation is successful,
49 .B mhbuild
50 will replace the original file with the new MIME message.  It will rename
51 the original file to start with the \*(lq,\*(rq character and end with the
52 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
53 it will be renamed to \*(lq,draft.orig\*(rq.  This allows you to easily
54 recover the
55 .B mhbuild
56 input file.
57 .SS "Listing the Contents"
58 The
59 .B \-list
60 switch tells
61 .B mhbuild
62 to list the table of contents associated with the MIME message that is created.
63 .PP
64 The
65 .B \-headers
66 switch indicates
67 that a one-line banner should be displayed above the listing.  The
68 .B \-realsize
69 switch tells
70 .B mhbuild
71 to evaluate the \*(lqnative\*(rq
72 (decoded) format of each content prior to listing.  This provides an
73 accurate count at the expense of a small delay.  If the
74 .B \-verbose
75 switch
76 is present, then the listing will show any \*(lqextra\*(rq information
77 that is present in the message, such as comments in the
78 \*(lqContent-Type\*(rq header.
79 .SS "Translating the Composition File"
80 .B mhbuild
81 is essentially a filter to aid in the composition of MIME
82 messages.
83 .B mhbuild
84 will convert an
85 .B mhbuild
86 \*(lqcomposition file\*(rq
87 into a valid MIME message.  A
88 .B mhbuild
89 \*(lqcomposition file\*(rq
90 is just a file containing plain text that is interspersed
91 with various
92 .B mhbuild
93 directives.  When this file is processed
94 by
95 .BR mhbuild ,
96 the various directives will be expanded to the
97 appropriate content, and will be encoded according to the MIME standards.
98 The resulting MIME message can then be sent by electronic mail.
99 .PP
100 The formal syntax for a
101 .B mhbuild
102 composition file is defined at the
103 end of this document, but the ideas behind this format are not complex.
104 Basically, the body contains one or more contents.  A content consists of
105 either a directive, indicated with a \*(lq#\*(rq as the first character
106 of a line; or, plaintext (one or more lines of text).  The continuation
107 character, \*(lq\\\*(lq, may be used to enter a single directive on more
108 than one line, e.g.,
109 .PP
110 .RS 5
111 .nf
112 #image/png \\
113     /home/foobar/junk/picture.png
114 .fi
115 .RE
116 .PP
117 There are four kinds of directives:
118 \*(lqtype\*(rq,
119 \*(lqexternal-type\*(rq,
120 \*(lqmessage\*(rq (#forw),
121 and \*(lqbegin\*(rq (#begin).
122 .PP
123 .B "(1) The \*(lqtype\*(rq directive
124 is used to directly specify the type and
125 subtype of a content.  You may only specify discrete types in this manner
126 (can't specify the types multipart or message with this directive).
127 You may optionally specify the name of a file containing the contents
128 in \*(lqnative\*(rq (decoded) format.  If this filename starts with the
129 \*(lq|\*(rq character, then it represents a command to execute whose
130 output is captured accordingly.
131 For example,
132 .PP
133 .RS 5
134 .nf
135 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
136 .fi
137 .RE
138 .PP
139 If a filename is not given,
140 .B mhbuild
141 will look for information in the
142 user's profile to determine how the different contents should be composed.
143 This is accomplished by consulting a composition string, and executing
144 it under
145 .BR /bin/sh ,
146 with the standard output set to the content.
147 If the
148 .B \-verbose
149 switch is given,
150 .B mhbuild
151 will echo any commands that are used to create contents in this way.
152 .PP
153 The composition string may contain the following escapes:
154 .PP
155 .RS 5
156 .nf
157 .ta \w'%P  'u
158 %a      Insert parameters from directive
159 %f      Insert filename containing content
160 %F      %f, and stdout is not re-directed
161 %s      Insert content subtype
162 %%      Insert character %
163 .fi
164 .RE
165 .PP
166 First,
167 .B mhbuild
168 will look for an entry of the form:
169 .PP
170 .RS 5
171 mhbuild-compose-<type>/<subtype>
172 .RE
173 .PP
174 to determine the command to use to compose the content.  If this isn't
175 found,
176 .B mhbuild
177 will look for an entry of the form:
178 .PP
179 .RS 5
180 mhbuild-compose-<type>
181 .RE
182 .PP
183 to determine the composition command. If this isn't found,
184 .B mhbuild
185 will complain.
186 .PP
187 An example entry might be:
188 .PP
189 .RS 5
190 mhbuild-compose-audio/basic: record | raw2audio -F
191 .RE
192 .PP
193 Because commands like these will vary, depending on the display
194 environment used for login, composition strings for different
195 contents should probably be put in the file specified by the
196 .B $MHBUILD
197 environment variable, instead of directly in your
198 user profile.
199 .PP
200 .B "(2) The \*(lqexternal-type\*(rq directives
201 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 .B "(3) The \*(lqmessage\*(rq directive (#forw)
249 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 .B "(4) The \*(lqbegin\*(rq directive
288 is used to create a multipart content.
289 When using the \*(lqbegin\*(rq directive, you must specify at least one
290 content between the begin and end pairs.
291 .PP
292 .RS 5
293 .nf
294 #begin
295 This will be a multipart with only one part.
296 #end
297 .fi
298 .RE
299 .PP
300 If you use multiple directives in a composition draft,
301 .B mhbuild
302 will
303 automatically encapsulate them inside a multipart content.  Therefore the
304 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
305 multiparts, or create a multipart message containing only one part.
306 .PP
307 For all of these directives, the user may include a brief description
308 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
309 character.  This description will be copied into the
310 \*(lqContent-Description\*(rq header when the directive is processed.
311 .PP
312 .RS 5
313 .nf
314 #forw [important mail from Bob] +bob 1 2 3 4 5
315 .fi
316 .RE
317 .PP
318 Similarly, a disposition string may optionally be provided between
319 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
320 \*(lqContent-Disposition\*(rq header when the directive is processed.
321 If a disposition string is provided that does not contain a filename
322 parameter, and a filename is provided in the directive, it will be
323 added to the \*(lqContent-Disposition\*(rq header.  For example, the
324 following directive:
325 .PP
326 .RS 5
327 .nf
328 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
329 .fi
330 .RE
331 .PP
332 creates these message part headers:
333 .PP
334 .RS 5
335 .nf
336 Content-Type: text/plain; charset="iso-8859-1"
337 Content-Disposition: attachment; filename="summary.txt"
338 .fi
339 .RE
340 .PP
341 By default,
342 .B mhbuild
343 will generate a unique \*(lqContent-ID:\*(rq for each directive,
344 corresponding to each message part; however, the user may override
345 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
346 characters.  The
347 .B \-nocontentid
348 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
349 even in the top level of the message.
350 .PP
351 In addition to the various directives, plaintext can be present.
352 Plaintext is gathered, until a directive is found or the draft is
353 exhausted, and this is made to form a text content.  If the plaintext
354 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
355 e.g.,
356 .PP
357 .RS 5
358 ##when sent, this line will start with only one #
359 .RE
360 .PP
361 If you want to end the plaintext prior to a directive, e.g., to have two
362 plaintext contents adjacent, simply insert a line containing a single
363 \*(lq#\*(rq character, e.g.,
364 .PP
365 .RS 5
366 .nf
367 this is the first content
368 #
369 and this is the second
370 .fi
371 .RE
372 .PP
373 Finally, if the plaintext starts with a line of the form:
374 .PP
375 .RS 5
376 Content-Description: text
377 .RE
378 .PP
379 then this will be used to describe the plaintext content.
380 You MUST follow this line with a blank line before starting
381 your text.
382 .PP
383 By default, plaintext is captured as a text/plain content.  You can
384 override this by starting the plaintext with \*(lq#<\*(rq followed by
385 a content-type specification.  For example, e.g.,
386 .PP
387 .RS 5
388 .nf
389 #<text/enriched
390 this content will be tagged as text/enriched
391 #
392 and this content will be tagged as text/plain
393 #
394 #<application/x-patch [this is a patch]
395 and this content will be tagged as application/x-patch
396 .fi
397 .RE
398 .PP
399 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
400 content-description must be on the same line which identifies the content
401 type of the plaintext.
402 .PP
403 When composing a text content, you may indicate the relevant character
404 set by adding the \*(lqcharset\*(rq parameter to the directive.
405 .PP
406 .RS 5
407 #<text/plain; charset=iso-8859-5
408 .RE
409 .PP
410 If a text content contains any 8\-bit characters (characters with the
411 high bit set) and the character set is not specified as above, then
412 .B mhbuild
413 will assume the character set is of the type given by the
414 environment variable MM_CHARSET.  If this environment variable is not
415 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
416 .PP
417 If a text content contains only 7\-bit characters and the character set
418 is not specified as above, then the character set will be labeled as
419 \*(lqus-ascii\*(rq.
420 .PP
421 Putting this all together,
422 here is an example of a more complicated message draft.  The
423 following draft will expand into a multipart/mixed message
424 containing five parts:
425 .PP
426 .RS 5
427 .nf
428 To: nobody@nowhere.org
429 Cc:
430 Subject: Look and listen to me!
431 --------
432 The first part will be text/plain
433 #<text/enriched
434 The second part will be text/enriched
435 #
436 This third part will be text/plain
437 #audio/basic [silly giggle]  \\
438     |raw2audio -F < /usr/lib/sounds/giggle.au
439 #image/gif   [photo of foobar] \\
440                     /home/foobar/lib/picture.gif
441 .fi
442 .RE
443
444 .SS "Transfer Encodings"
445 After
446 .B mhbuild
447 constructs the new MIME message by parsing directives,
448 including files, etc., it scans the contents of the message to determine
449 which transfer encoding to use.  It will check for 8bit data, long lines,
450 spaces at the end of lines, and clashes with multipart boundaries.  It will
451 then choose a transfer encoding appropriate for each content type.
452 .PP
453 The switch
454 .B \-ebcdicsafe
455 will cause
456 .B mhbuild
457 to slightly change
458 the way in which it performs the \*(lqquoted-printable\*(rq transfer
459 encoding.  Along with encoding 8\-bit characters, it will now also encode
460 certain common punctuation characters as well.  This slightly reduces the
461 readability of the message, but allows the message to pass more reliably
462 through mail gateways which involve the EBCDIC character encoding.
463
464 .SS "Invoking mhbuild"
465 Typically,
466 .B mhbuild
467 is invoked by the
468 .B send
469 program.
470 It expects an
471 .B mhbuild
472 composition file, which
473 .B send
474 will create, from the draft file, if MIME features are requested.
475 This is the case with attachment headers.
476 .PP
477 In contrast to previous versions, the user does not need to care
478 for any special actions anymore.
479
480 .SS "User Environment"
481 Because the environment in which
482 .B mhbuild
483 operates may vary for a
484 user,
485 .B mhbuild
486 will look for the environment variable
487 .BR $MHBUILD .
488 If present, this specifies the name of an additional user profile which
489 should be read.  Hence, when a user logs in on a particular machine,
490 this environment variable should be set to refer to a file containing
491 definitions useful for that machine.
492 .PP
493 Finally,
494 .B mhbuild
495 will attempt to consult a global
496 .B mhbuild
497 user profile, e.g.,
498 .PP
499 .RS 5
500 %etcdir%/mhn.defaults
501 .RE
502 .PP
503 if it exists.
504
505 .SS "Syntax of Composition Files"
506 The following is the formal syntax of a
507 .B mhbuild
508 \*(lqcomposition file\*(rq.
509 .PP
510 .RS 5
511 .nf
512 body         ::=     1*(content | EOL)
513
514 content      ::=     directive | plaintext
515
516 directive    ::=     "#" type "/" subtype
517                          0*(";" attribute "=" value)
518                          [ "(" comment ")" ]
519                          [ "<" id ">" ]
520                          [ "[" description "]" ]
521                          [ "{" disposition "}" ]
522                          [ filename ]
523                          EOL
524
525                    | "#@" type "/" subtype
526                          0*(";" attribute "=" value)
527                          [ "(" comment ")" ]
528                          [ "<" id ">" ]
529                          [ "[" description "]" ]
530                          [ "{" disposition "}" ]
531                          external-parameters
532                          EOL
533
534                    | "#forw"
535                          [ "<" id ">" ]
536                          [ "[" description "]" ]
537                          [ "{" disposition "}" ]
538                          [ "+"folder ] [ 0*msg ]
539                          EOL
540
541                    | "#begin"
542                            [ "<" id ">" ]
543                            [ "[" description "]" ]
544                            [ "{" disposition "}" ]
545                            [   "alternative"
546                              | "parallel"
547                              | something-else    ]
548                            EOL
549                          1*body
550                      "#end" EOL
551
552 plaintext    ::=     [ "Content-Description:"
553                            description EOL EOL ]
554                          1*line
555                      [ "#" EOL ]
556
557                    | "#<" type "/" subtype
558                          0*(";" attribute "=" value)
559                          [ "(" comment ")" ]
560                          [ "[" description "]" ]
561                          [ "{" disposition "}" ]
562                          EOL
563                          1*line
564                      [ "#" EOL ]
565
566 line         ::=     "##" text EOL
567                      -- interpreted as "#"text EOL
568                    | text EOL
569 .fi
570 .RE
571 .PP
572
573 .SH FILES
574 .fc ^ ~
575 .nf
576 .ta \w'%etcdir%/ExtraBigFileName  'u
577 ^$HOME/.mmh/profile~^The user profile
578 ^$MHBUILD~^Additional profile entries
579 ^%etcdir%/mhn.defaults~^System default MIME profile entries
580 .fi
581
582 .SH "PROFILE COMPONENTS"
583 .fc ^ ~
584 .nf
585 .ta 2.4i
586 .ta \w'ExtraBigProfileName  'u
587 ^Path:~^To determine the user's mail storage
588 ^Current\-Folder:~^To find the default current folder
589 ^mhbuild-compose-<type>*~^Template for composing contents
590 .fi
591
592 .SH "SEE ALSO"
593 mhlist(1), mhshow(1), mhstore(1),
594 .br
595 .I "Proposed Standard for Message Encapsulation"
596 (RFC\-934),
597 .br
598 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
599 (RFC\-2045),
600 .br
601 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
602 (RFC\-2046),
603 .br
604 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
605 (RFC\-2047),
606 .br
607 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
608 (RFC\-2048),
609 .br
610 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
611 (RFC\-2049)
612
613 .SH DEFAULTS
614 .nf
615 .RB ` \-headers '
616 .RB ` \-realsize '
617 .RB ` \-norfc934mode '
618 .RB ` \-contentid '
619 .RB ` \-noebcdicsafe '
620 .RB ` \-noverbose '
621 .fi
622
623 .SH CONTEXT
624 If a folder is given, it will become the current folder.  The last
625 message selected will become the current message.