5 .\" include the -mh macro file
8 .TH MHBUILD %manext1% MH.6.8 [%nmhversion%]
10 mhbuild \- translate MIME composition draft
16 \%[\-list] \%[-nolist]
17 \%[\-realsize] \%[\-norealsize]
19 \%[\-headers] \%[\-noheaders]
20 \%[\-ebcdicsafe] \%[\-noebcdicsafe]
22 \%[\-rfc934mode] \%[\-norfc934mode]
23 \%[\-verbose] \%[\-noverbose]
25 \%[\-check] \%[\-nocheck]
30 The \fImhbuild\fR command will translate a MIME composition draft into
33 \fImhbuild\fR creates multi-media messages as specified in RFC\-2045
34 thru RFC\-2049. Currently \fImhbuild\fR only supports encodings in
35 message bodies, and does not support the encoding of message headers as
36 specified in RFC\-2047.
38 If you specify the name of the composition file as \*(lq-\*(rq,
39 then \fImhbuild\fR will accept the composition draft on the standard
40 input. If the translation of this input is successful, \fImhbuild\fR
41 will output the new MIME message to the standard output. This argument
42 must be the last argument on the command line.
44 Otherwise if the file argument to \fImhbuild\fR is the name of a valid
45 composition file, and the translation is successful, \fImhbuild\fR will
46 replace the original file with the new MIME message. It will rename
47 the original file to start with the \*(lq,\*(rq character and end with the
48 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
49 it will be renamed to \*(lq,draft.orig\*(rq. This allows you to easily
50 recover the \fImhbuild\fR input file.
52 .Uh "Listing the Contents"
53 The `\-list' switch tells \fImhbuild\fR to list the table of contents
54 associated with the MIME message that is created.
56 The `\-headers' switch indicates
57 that a one-line banner should be displayed above the listing. The
58 `\-realsize' switch tells \fImhbuild\fR to evaluate the \*(lqnative\*(rq
59 (decoded) format of each content prior to listing. This provides an
60 accurate count at the expense of a small delay. If the `\-verbose' switch
61 is present, then the listing will show any \*(lqextra\*(rq information
62 that is present in the message, such as comments in the Content-Type header.
64 .Uh "Translating the Composition File"
65 \fImhbuild\fR is essentially a filter to aid in the composition of MIME
66 messages. \fImhbuild\fR will convert an
67 \fImhbuild\fR \*(lqcomposition file\*(rq
68 into a valid MIME message. A \fImhbuild\fR \*(lqcomposition file\*(rq
69 is just a file containing plain text that is interspersed
70 with various \fImhbuild\fR directives. When this file is processed
71 by \fImhbuild\fR, the various directives will be expanded to the
72 appropriate content, and will be encoded according to the MIME standards.
73 The resulting MIME message can then be sent by electronic mail.
75 The formal syntax for a \fImhbuild\fR composition file is defined at the
76 end of this document, but the ideas behind this format are not complex.
77 Basically, the body contains one or more contents. A content consists of
78 either a directive, indicated with a \*(lq#\*(rq as the first character
79 of a line; or, plaintext (one or more lines of text). The continuation
80 character, \*(lq\\\*(lq, may be used to enter a single directive on more
86 /home/foobar/junk/picture.png
90 There are four kinds of directives: \*(lqtype\*(rq directives, which
91 name the type and subtype of the content; \*(lqexternal-type\*(rq
92 directives, which also name the type and subtype of the content; the
93 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
94 more messages; and, the \*(lqbegin\*(rq directive (#begin), which is
95 used to create a multipart content.
97 The \*(lqtype\*(rq directive is used to directly specify the type and
98 subtype of a content. You may only specify discrete types in this manner
99 (can't specify the types multipart or message with this directive).
100 You may optionally specify the name of a file containing the contents
101 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
102 \*(lq|\*(rq character, then it represents a command to execute whose
103 output is captured accordingly.
108 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
112 If a filename is not given, \fImhbuild\fR will look for information in the
113 user's profile to determine how the different contents should be composed.
114 This is accomplished by consulting a composition string, and executing
115 it under \fB/bin/sh\fR, with the standard output set to the content.
116 If the `\-verbose' switch is given, \fImhbuild\fR will echo any commands
117 that are used to create contents in this way.
119 The composition string may contain the following escapes:
124 %a Insert parameters from directive
125 %f Insert filename containing content
126 %F %f, and stdout is not re-directed
127 %s Insert content subtype
128 %% Insert character %
135 \fImhbuild\fR will look for an entry of the form:
138 mhbuild-compose-<type>/<subtype>
141 to determine the command to use to compose the content. If this isn't
142 found, \fImhbuild\fR will look for an entry of the form:
145 mhbuild-compose-<type>
148 to determine the composition command.
150 If this isn't found, \fImhbuild\fR
153 An example entry might be:
156 mhbuild-compose-audio/basic: record | raw2audio -F
159 Because commands like these will vary, depending on the display
160 environment used for login, composition strings for different
161 contents should probably be put in the file specified by the
162 \fB$MHBUILD\fR environment variable, instead of directly in your
165 The \*(lqexternal-type\*(rq directives are used to provide a MIME
166 reference to a content, rather than enclosing the contents itself
167 (for instance, by specifying an ftp site). Hence, instead of
168 providing a filename as with the type directives, external-parameters
169 are supplied. These look like regular parameters, so they must be
170 separated accordingly. For example,
174 #@application/octet-stream; \\
176 conversions=compress \\
177 [this is the nmh distribution] \\
178 name="nmh.tar.gz"; \\
179 directory="/pub/nmh"; \\
180 site="ftp.math.gatech.edu"; \\
181 access-type=anon-ftp; \\
186 You must give a description string to separate the content parameters
187 from the external-parameters (although this string may be empty).
188 This description string is specified by enclosing it within
191 These parameters are of the form:
195 .ta \w'access-type= 'u
196 access-type= usually \fIanon-ftp\fR or \fImail-server\fR
198 permission= read-only or read-write
200 directory= directoryname (optional)
201 mode= usually \fIascii\fR or \fIimage\fR (optional)
202 size= number of octets
204 subject= subject to send
205 body= command to send for retrieval
211 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
212 group of messages to include. You may optionally specify the name of
213 the folder and which messages are to be forwarded. If a folder is not
214 given, it defaults to the current folder. Similarly, if a message is not
215 given, it defaults to the current message. Hence, the message directive
216 is similar to the \fIforw\fR\0(1) command, except that the former uses
217 the MIME rules for encapsulation rather than those specified in RFC\-934.
222 #forw +inbox 42 43 99
226 If you include a single message, it will be included directly as a content
227 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
228 then \fImhbuild\fR will add a content of type \*(lqmultipart/digest\*(rq
229 and include each message as a subpart of this content.
231 If you are using this directive to include more than one message, you
232 may use the `\-rfc934mode' switch. This switch will indicate that
233 \fImhbuild\fR should attempt to utilize the MIME encapsulation rules
234 in such a way that the \*(lqmultipart/digest\*(rq that is created
235 is (mostly) compatible with the encapsulation specified in RFC\-934.
236 If given, then RFC\-934 compliant user-agents should be able to burst the
237 message on reception\0--\0providing that the messages being encapsulated
238 do not contain encapsulated messages themselves. The drawback of this
239 approach is that the encapsulations are generated by placing an extra
240 newline at the end of the body of each message.
242 The \*(lqbegin\*(rq directive is used to create a multipart content.
243 When using the \*(lqbegin\*(rq directive, you must specify at least one
244 content between the begin and end pairs.
249 This will be a multipart with only one part.
254 If you use multiple directives in a composition draft, \fImhbuild\fR will
255 automatically encapsulate them inside a multipart content. Therefore the
256 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
257 multiparts, or create a multipart message containing only one part.
259 For all of these directives, the user may include a brief description
260 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
261 character. This description will be copied into the
262 \*(lqContent-Description\*(rq header when the directive is processed.
266 #forw [important mail from Bob] +bob 1 2 3 4 5
270 By default, \fImhbuild\fR will generate a unique \*(lqContent-ID:\*(rq for
271 each directive; however, the user may override this by defining the ID
272 using the \*(lq<\*(rq and \*(lq>\*(rq characters.
274 In addition to the various directives, plaintext can be present.
275 Plaintext is gathered, until a directive is found or the draft is
276 exhausted, and this is made to form a text content. If the plaintext
277 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
282 ##when sent, this line will start with only one #
285 If you want to end the plaintext prior to a directive, e.g., to have two
286 plaintext contents adjacent, simply insert a line containing a single
287 \*(lq#\*(rq character,
293 this is the first content
295 and this is the second
300 if the plaintext starts with a line of the form:
303 Content-Description: text
306 then this will be used to describe the plaintext content.
307 You MUST follow this line with a blank line before starting
310 By default, plaintext is captured as a text/plain content. You can
311 override this by starting the plaintext with \*(lq#<\*(rq followed by
312 a content-type specification. For example,
319 this content will be tagged as text/enriched
321 and this content will be tagged as text/plain
323 #<application/x-patch [this is a patch]
324 and this content will be tagged as application/x-patch
328 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
329 content-description must be on the same line which identifies the content
330 type of the plaintext.
332 When composing a text content, you may indicate the relevant character
333 set by adding the \*(lqcharset\*(rq parameter to the directive.
336 #<text/plain; charset=iso-8859-5
339 If a text content contains any 8bit characters (characters with the
340 high bit set) and the character set is not specified as above, then
341 \fImhbuild\fR will assume the character set is of the type given by the
342 environment variable MM_CHARSET. If this environment variable is not
343 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
345 If a text content contains only 7bit characters and the character set
346 is not specified as above, then the character set will be labeled as
349 Putting this all together,
351 here is an example of a more complicated message draft. The
352 following draft will expand into a multipart/mixed message
353 containing five parts:
357 To: nobody@nowhere.org
359 Subject: Look and listen to me!
361 The first part will be text/plain
363 The second part will be text/enriched
365 This third part will be text/plain
366 #audio/basic [silly giggle] \\
367 |raw2audio -F < /usr/lib/sounds/giggle.au
368 #image/gif [photo of foobar] \\
369 /home/foobar/lib/picture.gif
373 .Uh "Integrity Check"
374 If \fImhbuild\fR is given the `-check' switch, then it will also associate
375 an integrity check with each \*(lqleaf\*(rq content. This will add a
376 Content-MD5 header field to the content, along with the md5 sum of the
377 unencoded contents. This may be used by the receiver of the message to
378 verify that the contents of the message were not changed in transport.
380 .Uh "Transfer Encodings"
381 After \fImhbuild\fR constructs the new MIME message by parsing directives,
382 including files, etc., it scans the contents of the message to determine
383 which transfer encoding to use. It will check for 8bit data, long lines,
384 spaces at the end of lines, and clashes with multipart boundaries. It will
385 then choose a transfer encoding appropriate for each content type.
387 If an integrity check is being associated with each content by using
388 the `\-check' switch, then \fImhbuild\fR will encode each content with
389 a transfer encoding, even it the content contains only 7bit data. This
390 is to increase the likelihood that the content is not changed while in
393 The switch `\-ebcdicsafe' will cause \fImhbuild\fR to slightly change
394 the way in which it performs the \*(lqquoted-printable\*(rq transfer
395 encoding. Along with encoding 8bit characters, it will now also encode
396 certain common punctuation characters as well. This slightly reduces the
397 readability of the message, but allows the message to pass more reliably
398 through mail gateways which involve the EBCDIC character encoding.
400 .Uh "Invoking mhbuild"
401 Typically, \fImhbuild\fR is invoked by the \fIwhatnow\fR program. This
402 command will expect the body of the draft to be formatted as an
403 \fImhbuild\fR composition file. Once you have composed this input file
404 using a command such as \fIcomp\fR, \fIrepl\fR, or \fIforw\fR, you invoke
405 \fImhbuild\fR at the \*(lqWhat now\*(rq prompt with
411 prior to sending the draft. This will cause \fIwhatnow\fR to execute
412 \fImhbuild\fR to translate the composition file into MIME format.
414 It is also possible to have the \fIwhatnow\fR program invoke \fImhbuild\fR
415 automatically when a message is sent. To do this, you must add the line
421 to your \&.mh\(ruprofile file.
423 Finally, you should consider adding this line to your profile:
429 This way, if you decide to \fBlist\fR after invoking \fImime\fR,
436 will work as you expect.
438 .Uh "User Environment"
439 Because the environment in which \fImhbuild\fR operates may vary for a
440 user, \fImhbuild\fR will look for the environment variable \fB$MHBUILD\fR.
441 If present, this specifies the name of an additional user profile which
442 should be read. Hence, when a user logs in on a particular machine,
443 this environment variable should be set to refer to a file containing
444 definitions useful for that machine.
446 Finally, \fImhbuild\fR will attempt to consult a global \fImhbuild\fR
452 %etcdir%/mhn.defaults
457 .Uh "Syntax of Composition Files"
459 The following is the formal syntax of a \fImhbuild\fR
460 \*(lqcomposition file\*(rq.
464 body ::= 1*(content | EOL)
466 content ::= directive | plaintext
468 directive ::= "#" type "/" subtype
469 0*(";" attribute "=" value)
472 [ "[" description "]" ]
476 | "#@" type "/" subtype
477 0*(";" attribute "=" value)
480 [ "[" description "]" ]
486 [ "[" description "]" ]
487 [ "+"folder ] [ 0*msg ]
492 [ "[" description "]" ]
500 plaintext ::= [ "Content-Description:"
501 description EOL EOL ]
505 | "#<" type "/" subtype
506 0*(";" attribute "=" value)
508 [ "[" description "]" ]
513 line ::= "##" text EOL
514 -- interpreted as "#"text EOL
520 ^$HOME/\&.mh\(ruprofile~^The user profile
521 ^$MHBUILD~^Additional profile entries
522 ^%etcdir%/mhn.defaults~^System default MIME profile entries
524 ^Path:~^To determine the user's nmh directory
526 ^Current\-Folder:~^To find the default current folder
528 ^mhbuild-compose-<type>*~^Template for composing contents
530 mhlist(1), mhshow(1), mhstore(1)
534 \fIProposed Standard for Message Encapsulation\fR,
538 \fIMultipurpose Internet Mail Extensions (MIME) Part One:
540 Format of Internet Message Bodies\fR,
544 \fIMultipurpose Internet Mail Extensions (MIME) Part Two:
550 \fIMultipurpose Internet Mail Extensions (MIME) Part Three:
552 Message Header Extensions for Non-ASCII Text\fR,
556 \fIMultipurpose Internet Mail Extensions (MIME) Part Four:
558 Registration Procedures\fR,
562 \fIMultipurpose Internet Mail Extensions (MIME) Part Five:
564 Conformance Criteria and Examples\fR.
578 If a folder is given, it will become the current folder. The last
579 message selected will become the current message.