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