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