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