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