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