4fa75b529da7c798b07d1387e91cd120928eb8a9
[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 three kinds of directives:
118 \*(lqtype\*(rq,
119 \*(lqmessage\*(rq (#forw),
120 and \*(lqbegin\*(rq (#begin).
121 .PP
122 .B "(1) The \*(lqtype\*(rq directive
123 is used to directly specify the type and
124 subtype of a content.  You may only specify discrete types in this manner
125 (can't specify the types multipart or message with this directive).
126 You may optionally specify the name of a file containing the contents
127 in \*(lqnative\*(rq (decoded) format.  If this filename starts with the
128 \*(lq|\*(rq character, then it represents a command to execute whose
129 output is captured accordingly.
130 For example,
131 .PP
132 .RS 5
133 .nf
134 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
135 .fi
136 .RE
137 .PP
138 If a filename is not given,
139 .B mhbuild
140 will look for information in the
141 user's profile to determine how the different contents should be composed.
142 This is accomplished by consulting a composition string, and executing
143 it under
144 .BR /bin/sh ,
145 with the standard output set to the content.
146 If the
147 .B \-verbose
148 switch is given,
149 .B mhbuild
150 will echo any commands that are used to create contents in this way.
151 .PP
152 The composition string may contain the following escapes:
153 .PP
154 .RS 5
155 .nf
156 .ta \w'%P  'u
157 %a      Insert parameters from directive
158 %f      Insert filename containing content
159 %F      %f, and stdout is not re-directed
160 %s      Insert content subtype
161 %%      Insert character %
162 .fi
163 .RE
164 .PP
165 First,
166 .B mhbuild
167 will look for an entry of the form:
168 .PP
169 .RS 5
170 mhbuild-compose-<type>/<subtype>
171 .RE
172 .PP
173 to determine the command to use to compose the content.  If this isn't
174 found,
175 .B mhbuild
176 will look for an entry of the form:
177 .PP
178 .RS 5
179 mhbuild-compose-<type>
180 .RE
181 .PP
182 to determine the composition command. If this isn't found,
183 .B mhbuild
184 will complain.
185 .PP
186 An example entry might be:
187 .PP
188 .RS 5
189 mhbuild-compose-audio/basic: record | raw2audio -F
190 .RE
191 .PP
192 Because commands like these will vary, depending on the display
193 environment used for login, composition strings for different
194 contents should probably be put in the file specified by the
195 .B $MHBUILD
196 environment variable, instead of directly in your
197 user profile.
198 .PP
199 .B "(2) The \*(lqmessage\*(rq directive (#forw)
200 is used to specify a message or
201 group of messages to include.  You may optionally specify the name of
202 the folder and which messages are to be forwarded.  If a folder is not
203 given, it defaults to the current folder.  Similarly, if a message is not
204 given, it defaults to the current message.  Hence, the message directive
205 is similar to the
206 .B forw
207 command, except that the former uses
208 the MIME rules for encapsulation rather than those specified in RFC\-934.
209 For example,
210 .PP
211 .RS 5
212 .nf
213 #forw +inbox 42 43 99
214 .fi
215 .RE
216 .PP
217 If you include a single message, it will be included directly as a content
218 of type \*(lqmessage/rfc822\*(rq.  If you include more than one message,
219 then
220 .B mhbuild
221 will add a content of type \*(lqmultipart/digest\*(rq
222 and include each message as a subpart of this content.
223 .PP
224 If you are using this directive to include more than one message, you
225 may use the
226 .B \-rfc934mode
227 switch.  This switch will indicate that
228 .B mhbuild
229 should attempt to utilize the MIME encapsulation rules
230 in such a way that the \*(lqmultipart/digest\*(rq that is created
231 is (mostly) compatible with the encapsulation specified in RFC\-934.
232 If given, then RFC\-934 compliant user-agents should be able to burst the
233 message on reception\0--\0providing that the messages being encapsulated
234 do not contain encapsulated messages themselves.  The drawback of this
235 approach is that the encapsulations are generated by placing an extra
236 newline at the end of the body of each message.
237 .PP
238 .B "(3) The \*(lqbegin\*(rq directive
239 is used to create a multipart content.
240 When using the \*(lqbegin\*(rq directive, you must specify at least one
241 content between the begin and end pairs.
242 .PP
243 .RS 5
244 .nf
245 #begin
246 This will be a multipart with only one part.
247 #end
248 .fi
249 .RE
250 .PP
251 If you use multiple directives in a composition draft,
252 .B mhbuild
253 will
254 automatically encapsulate them inside a multipart content.  Therefore the
255 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
256 multiparts, or create a multipart message containing only one part.
257 .PP
258 For all of these directives, the user may include a brief description
259 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
260 character.  This description will be copied into the
261 \*(lqContent-Description\*(rq header when the directive is processed.
262 .PP
263 .RS 5
264 .nf
265 #forw [important mail from Bob] +bob 1 2 3 4 5
266 .fi
267 .RE
268 .PP
269 Similarly, a disposition string may optionally be provided between
270 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
271 \*(lqContent-Disposition\*(rq header when the directive is processed.
272 If a disposition string is provided that does not contain a filename
273 parameter, and a filename is provided in the directive, it will be
274 added to the \*(lqContent-Disposition\*(rq header.  For example, the
275 following directive:
276 .PP
277 .RS 5
278 .nf
279 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
280 .fi
281 .RE
282 .PP
283 creates these message part headers:
284 .PP
285 .RS 5
286 .nf
287 Content-Type: text/plain; charset="iso-8859-1"
288 Content-Disposition: attachment; filename="summary.txt"
289 .fi
290 .RE
291 .PP
292 By default,
293 .B mhbuild
294 will generate a unique \*(lqContent-ID:\*(rq for each directive,
295 corresponding to each message part; however, the user may override
296 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
297 characters.  The
298 .B \-nocontentid
299 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
300 even in the top level of the message.
301 .PP
302 In addition to the various directives, plaintext can be present.
303 Plaintext is gathered, until a directive is found or the draft is
304 exhausted, and this is made to form a text content.  If the plaintext
305 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
306 e.g.,
307 .PP
308 .RS 5
309 ##when sent, this line will start with only one #
310 .RE
311 .PP
312 If you want to end the plaintext prior to a directive, e.g., to have two
313 plaintext contents adjacent, simply insert a line containing a single
314 \*(lq#\*(rq character, e.g.,
315 .PP
316 .RS 5
317 .nf
318 this is the first content
319 #
320 and this is the second
321 .fi
322 .RE
323 .PP
324 Finally, if the plaintext starts with a line of the form:
325 .PP
326 .RS 5
327 Content-Description: text
328 .RE
329 .PP
330 then this will be used to describe the plaintext content.
331 You MUST follow this line with a blank line before starting
332 your text.
333 .PP
334 By default, plaintext is captured as a text/plain content.  You can
335 override this by starting the plaintext with \*(lq#<\*(rq followed by
336 a content-type specification.  For example, e.g.,
337 .PP
338 .RS 5
339 .nf
340 #<text/enriched
341 this content will be tagged as text/enriched
342 #
343 and this content will be tagged as text/plain
344 #
345 #<application/x-patch [this is a patch]
346 and this content will be tagged as application/x-patch
347 .fi
348 .RE
349 .PP
350 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
351 content-description must be on the same line which identifies the content
352 type of the plaintext.
353 .PP
354 When composing a text content, you may indicate the relevant character
355 set by adding the \*(lqcharset\*(rq parameter to the directive.
356 .PP
357 .RS 5
358 #<text/plain; charset=iso-8859-5
359 .RE
360 .PP
361 If a text content contains any 8\-bit characters (characters with the
362 high bit set) and the character set is not specified as above, then
363 .B mhbuild
364 will assume the character set is of the type given by the
365 environment variable MM_CHARSET.  If this environment variable is not
366 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
367 .PP
368 If a text content contains only 7\-bit characters and the character set
369 is not specified as above, then the character set will be labeled as
370 \*(lqus-ascii\*(rq.
371 .PP
372 Putting this all together,
373 here is an example of a more complicated message draft.  The
374 following draft will expand into a multipart/mixed message
375 containing five parts:
376 .PP
377 .RS 5
378 .nf
379 To: nobody@nowhere.org
380 Cc:
381 Subject: Look and listen to me!
382 --------
383 The first part will be text/plain
384 #<text/enriched
385 The second part will be text/enriched
386 #
387 This third part will be text/plain
388 #audio/basic [silly giggle]  \\
389     |raw2audio -F < /usr/lib/sounds/giggle.au
390 #image/gif   [photo of foobar] \\
391                     /home/foobar/lib/picture.gif
392 .fi
393 .RE
394
395 .SS "Transfer Encodings"
396 After
397 .B mhbuild
398 constructs the new MIME message by parsing directives,
399 including files, etc., it scans the contents of the message to determine
400 which transfer encoding to use.  It will check for 8bit data, long lines,
401 spaces at the end of lines, and clashes with multipart boundaries.  It will
402 then choose a transfer encoding appropriate for each content type.
403 .PP
404 The switch
405 .B \-ebcdicsafe
406 will cause
407 .B mhbuild
408 to slightly change
409 the way in which it performs the \*(lqquoted-printable\*(rq transfer
410 encoding.  Along with encoding 8\-bit characters, it will now also encode
411 certain common punctuation characters as well.  This slightly reduces the
412 readability of the message, but allows the message to pass more reliably
413 through mail gateways which involve the EBCDIC character encoding.
414
415 .SS "Invoking mhbuild"
416 Typically,
417 .B mhbuild
418 is invoked by the
419 .B send
420 program.
421 It expects an
422 .B mhbuild
423 composition file, which
424 .B send
425 will create, from the draft file, if MIME features are requested.
426 This is the case with attachment headers.
427 .PP
428 In contrast to previous versions, the user does not need to care
429 for any special actions anymore.
430
431 .SS "User Environment"
432 Because the environment in which
433 .B mhbuild
434 operates may vary for a
435 user,
436 .B mhbuild
437 will look for the environment variable
438 .BR $MHBUILD .
439 If present, this specifies the name of an additional user profile which
440 should be read.  Hence, when a user logs in on a particular machine,
441 this environment variable should be set to refer to a file containing
442 definitions useful for that machine.
443 .PP
444 Finally,
445 .B mhbuild
446 will attempt to consult a global
447 .B mhbuild
448 user profile, e.g.,
449 .PP
450 .RS 5
451 %etcdir%/mhn.defaults
452 .RE
453 .PP
454 if it exists.
455
456 .SS "Syntax of Composition Files"
457 The following is the formal syntax of a
458 .B mhbuild
459 \*(lqcomposition file\*(rq.
460 .PP
461 .RS 5
462 .nf
463 body         ::=     1*(content | EOL)
464
465 content      ::=     directive | plaintext
466
467 directive    ::=     "#" type "/" subtype
468                          0*(";" attribute "=" value)
469                          [ "(" comment ")" ]
470                          [ "<" id ">" ]
471                          [ "[" description "]" ]
472                          [ "{" disposition "}" ]
473                          [ filename ]
474                          EOL
475
476                    | "#forw"
477                          [ "<" id ">" ]
478                          [ "[" description "]" ]
479                          [ "{" disposition "}" ]
480                          [ "+"folder ] [ 0*msg ]
481                          EOL
482
483                    | "#begin"
484                            [ "<" id ">" ]
485                            [ "[" description "]" ]
486                            [ "{" disposition "}" ]
487                            [   "alternative"
488                              | "parallel"
489                              | something-else    ]
490                            EOL
491                          1*body
492                      "#end" EOL
493
494 plaintext    ::=     [ "Content-Description:"
495                            description EOL EOL ]
496                          1*line
497                      [ "#" EOL ]
498
499                    | "#<" type "/" subtype
500                          0*(";" attribute "=" value)
501                          [ "(" comment ")" ]
502                          [ "[" description "]" ]
503                          [ "{" disposition "}" ]
504                          EOL
505                          1*line
506                      [ "#" EOL ]
507
508 line         ::=     "##" text EOL
509                      -- interpreted as "#"text EOL
510                    | text EOL
511 .fi
512 .RE
513 .PP
514
515 .SH FILES
516 .fc ^ ~
517 .nf
518 .ta \w'%etcdir%/ExtraBigFileName  'u
519 ^$HOME/.mmh/profile~^The user profile
520 ^$MHBUILD~^Additional profile entries
521 ^%etcdir%/mhn.defaults~^System default MIME profile entries
522 .fi
523
524 .SH "PROFILE COMPONENTS"
525 .fc ^ ~
526 .nf
527 .ta 2.4i
528 .ta \w'ExtraBigProfileName  'u
529 ^Path:~^To determine the user's mail storage
530 ^Current\-Folder:~^To find the default current folder
531 ^mhbuild-compose-<type>*~^Template for composing contents
532 .fi
533
534 .SH "SEE ALSO"
535 mhlist(1), show(1), mhstore(1),
536 .br
537 .I "Proposed Standard for Message Encapsulation"
538 (RFC\-934),
539 .br
540 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
541 (RFC\-2045),
542 .br
543 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
544 (RFC\-2046),
545 .br
546 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
547 (RFC\-2047),
548 .br
549 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
550 (RFC\-2048),
551 .br
552 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
553 (RFC\-2049)
554
555 .SH DEFAULTS
556 .nf
557 .RB ` \-headers '
558 .RB ` \-realsize '
559 .RB ` \-norfc934mode '
560 .RB ` \-contentid '
561 .RB ` \-noebcdicsafe '
562 .RB ` \-noverbose '
563 .fi
564
565 .SH CONTEXT
566 If a folder is given, it will become the current folder.  The last
567 message selected will become the current message.