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