1 .TH MHBUILD %manext1% "March 21, 2013" "%nmhversion%"
6 mhbuild \- translate MIME composition draft
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 ]
29 command will translate a MIME composition draft into
33 creates multi-media messages as specified in RFC 2045
34 to RFC 2049. This includes the encoding of message headers as specified
37 If you specify the name of the composition file as \*(lq-\*(rq,
40 will accept the composition draft on the standard
41 input. If the translation of this input is successful,
43 will output the new MIME message to the standard output. This argument
44 must be the last argument on the command line.
46 Otherwise if the file argument to
48 is the name of a valid
49 composition file, and the translation is successful,
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
58 .SS "Listing the Contents"
63 to list the table of contents associated with the MIME message that is created.
68 that a one-line banner should be displayed above the listing. The
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
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.
83 switch will indicate which algorithm to use when encoding any message headers
84 that contain 8\-bit characters. The valid arguments are
86 for based\-64 encoding and
88 for quoted\-printable encoding. The
89 .B \-autoheaderencoding
92 to automatically pick the encoding algorithm based on the frequency of
94 .SS "Translating the Composition File"
96 is essentially a filter to aid in the composition of MIME
101 \*(lqcomposition file\*(rq
102 into a valid MIME message. A
104 \*(lqcomposition file\*(rq
105 is just a file containing plain text that is interspersed
108 directives. When this file is processed
111 the various directives will be expanded to the
112 appropriate content, and will be encoded according to the MIME standards.
113 The resulting MIME message can then be sent by electronic mail.
115 The formal syntax for a
117 composition file is defined at the
118 end of this document, but the ideas behind this format are not complex.
119 Basically, the body contains one or more contents. A content consists of
120 either a directive, indicated with a \*(lq#\*(rq as the first character
121 of a line; or, plaintext (one or more lines of text). The continuation
122 character, \*(lq\\\*(lq, may be used to enter a single directive on more
128 /home/foobar/junk/picture.png
132 There are five kinds of directives: \*(lqtype\*(rq directives, which
133 name the type and subtype of the content; \*(lqexternal-type\*(rq
134 directives, which also name the type and subtype of the content; the
135 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
136 more messages; the \*(lqbegin\*(rq directive (#begin), which is
137 used to create a multipart content; and the \*(lqon/off/pop\*(rq
138 directives (#on, #off, #pop) which control whether any other
139 directives are honored at all.
143 switch allows control over whether mhbuild will honor any of the
144 \*(lq#\*(rq-directives. This can also be affected with the #on or
145 #off directives, and #pop, which restores the state of processing to
146 that preceding the most recent #on or #off. (The #on, #off, and #pop
147 directives are always honored, of course.) This allows inclusion of
148 plain text which looks like mhbuild directives, without causing
155 printf("Hello, World!);
160 Currently the stack depth for the #on/off/pop directives is 32.
162 The \*(lqtype\*(rq directive is used to directly specify the type and
163 subtype of a content. You may only specify discrete types in this manner
164 (can't specify the types multipart or message with this directive).
165 You may optionally specify the name of a file containing the contents
166 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
167 \*(lq|\*(rq character, then it represents a command to execute whose
168 output is captured accordingly.
173 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
177 If a filename is not given,
179 will look for information in the
180 user's profile to determine how the different contents should be composed.
181 This is accomplished by consulting a composition string, and executing
184 with the standard output set to the content.
189 will echo any commands that are used to create contents in this way.
191 The composition string may contain the following escapes:
196 %a Insert parameters from directive
197 %f Insert filename containing content
198 %F %f, and stdout is not re-directed
199 %s Insert content subtype
200 %% Insert character %
206 will look for an entry of the form:
209 mhbuild-compose-<type>/<subtype>
212 to determine the command to use to compose the content. If this isn't
215 will look for an entry of the form:
218 mhbuild-compose-<type>
221 to determine the composition command. If this isn't found,
225 An example entry might be:
228 mhbuild-compose-audio/basic: record | raw2audio -F
231 Because commands like these will vary, depending on the display
232 environment used for login, composition strings for different
233 contents should probably be put in the file specified by the
235 environment variable, instead of directly in your
238 The \*(lqexternal-type\*(rq directives are used to provide a MIME
239 reference to a content, rather than enclosing the contents itself
240 (for instance, by specifying an ftp site). Hence, instead of
241 providing a filename as with the type directives, external-parameters
242 are supplied. These look like regular parameters, so they must be
243 separated accordingly. For example,
247 #@application/octet-stream; \\
249 conversions=compress \\
250 [this is the nmh distribution] \\
251 {attachment; filename="nmh.tar.gz"} \\
252 name="nmh.tar.gz"; \\
253 directory="/pub/nmh"; \\
254 site="ftp.math.gatech.edu"; \\
255 access-type=anon-ftp; \\
260 You must give a description string to separate the content parameters
261 from the external-parameters (although this string may be empty).
262 This description string is specified by enclosing it within
263 \*(lq[]\*(rq. A disposition string, to appear in a
264 \*(lqContent-Disposition\*(rq header, may appear in the optional
267 These parameters are of the form:
271 .ta \w'access-type= 'u
272 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
274 permission= read-only or read-write
276 directory= directoryname (optional)
277 mode= usually \fIascii\fR or \fIimage\fR (optional)
278 size= number of octets
280 subject= subject to send
281 body= command to send for retrieval
286 A mimimum \*(lqexternal\-type\*(rq directive for the
293 #@application/octet-stream [] access-type=url; \\
294 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
298 Any long URLs will be wrapped according to RFC 2017 rules.
300 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
301 group of messages to include. You may optionally specify the name of
302 the folder and which messages are to be forwarded. If a folder is not
303 given, it defaults to the current folder. Similarly, if a message is not
304 given, it defaults to the current message. Hence, the message directive
307 command, except that the former uses
308 the MIME rules for encapsulation rather than those specified in RFC 934.
313 #forw +inbox 42 43 99
317 If you include a single message, it will be included directly as a content
318 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
321 will add a content of type \*(lqmultipart/digest\*(rq
322 and include each message as a subpart of this content.
324 If you are using this directive to include more than one message, you
327 switch. This switch will indicate that
329 should attempt to utilize the MIME encapsulation rules
330 in such a way that the \*(lqmultipart/digest\*(rq that is created
331 is (mostly) compatible with the encapsulation specified in RFC 934.
332 If given, then RFC 934 compliant user-agents should be able to burst the
333 message on reception\0--\0providing that the messages being encapsulated
334 do not contain encapsulated messages themselves. The drawback of this
335 approach is that the encapsulations are generated by placing an extra
336 newline at the end of the body of each message.
338 The \*(lqbegin\*(rq directive is used to create a multipart content.
339 When using the \*(lqbegin\*(rq directive, you must specify at least one
340 content between the begin and end pairs.
345 This will be a multipart with only one part.
350 If you use multiple directives in a composition draft,
353 automatically encapsulate them inside a multipart content. Therefore the
354 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
355 multiparts, or create a multipart message containing only one part.
357 For all of these directives, the user may include a brief description
358 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
359 character. This description will be copied into the
360 \*(lqContent-Description\*(rq header when the directive is processed.
364 #forw [important mail from Bob] +bob 1 2 3 4 5
368 Similarly, a disposition string may optionally be provided between
369 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
370 \*(lqContent-Disposition\*(rq header when the directive is processed.
371 If a disposition string is provided that does not contain a filename
372 parameter, and a filename is provided in the directive, it will be
373 added to the \*(lqContent-Disposition\*(rq header. For example, the
378 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
382 creates these message part headers:
386 Content-Type: text/plain; charset="iso-8859-1"
387 Content-Disposition: attachment; filename="summary.txt"
393 will generate a unique \*(lqContent-ID:\*(rq for each directive,
394 corresponding to each message part; however, the user may override
395 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
398 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
399 even in the top level of the message.
401 In addition to the various directives, plaintext can be present.
402 Plaintext is gathered, until a directive is found or the draft is
403 exhausted, and this is made to form a text content. If the plaintext
404 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
408 ##when sent, this line will start with only one #
411 If you want to end the plaintext prior to a directive, e.g., to have two
412 plaintext contents adjacent, simply insert a line containing a single
413 \*(lq#\*(rq character, e.g.,
417 this is the first content
419 and this is the second
423 Finally, if the plaintext starts with a line of the form:
426 Content-Description: text
429 then this will be used to describe the plaintext content.
430 You MUST follow this line with a blank line before starting
433 By default, plaintext is captured as a text/plain content. You can
434 override this by starting the plaintext with \*(lq#<\*(rq followed by
435 a content-type specification. For example, e.g.,
440 this content will be tagged as text/enriched
442 and this content will be tagged as text/plain
444 #<application/x-patch [this is a patch]
445 and this content will be tagged as application/x-patch
449 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
450 content-description must be on the same line which identifies the content
451 type of the plaintext.
453 When composing a text content, you may indicate the relevant character
454 set by adding the \*(lqcharset\*(rq parameter to the directive.
457 #<text/plain; charset=iso-8859-5
460 If a text content contains any 8\-bit characters (characters with the
461 high bit set) and the character set is not specified as above, then
463 will assume the character set is of the type given by the
464 environment variable MM_CHARSET. If this environment variable is not
465 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
467 If a text content contains only 7\-bit characters and the character set
468 is not specified as above, then the character set will be labeled as
471 Putting this all together,
472 here is an example of a more complicated message draft. The
473 following draft will expand into a multipart/mixed message
474 containing five parts:
478 To: nobody@nowhere.org
480 Subject: Look and listen to me!
482 The first part will be text/plain
484 The second part will be text/enriched
486 This third part will be text/plain
487 #audio/basic [silly giggle] \\
488 |raw2audio -F < /usr/lib/sounds/giggle.au
489 #image/gif [photo of foobar] \\
490 /home/foobar/lib/picture.gif
493 .SS "Integrity Check"
498 switch, then it will also associate an integrity check with each
499 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
500 the content, along with the md5 sum of the unencoded contents, per RFC
501 1864. This may be used by the receiver of the message to verify that
502 the contents of the message were not changed in transport.
503 .SS "Transfer Encodings"
506 constructs the new MIME message by parsing directives,
507 including files, etc., it scans the contents of the message to determine
508 which transfer encoding to use. It will check for 8bit data, long lines,
509 spaces at the end of lines, and clashes with multipart boundaries. It will
510 then choose a transfer encoding appropriate for each content type.
512 If an integrity check is being associated with each content by using
517 will encode each content with
518 a transfer encoding, even it the content contains only 7\-bit data. This
519 is to increase the likelihood that the content is not changed while in
521 .SS "Invoking mhbuild"
527 command will expect the body of the draft to be formatted as an
529 composition file. Once you have composed this input file
530 using a command such as
537 at the \*(lqWhat now\*(rq prompt with
543 prior to sending the draft. This will cause
547 to translate the composition file into MIME format.
549 It is also possible to have the
553 automatically when a message is sent. To do this, you must add the line
563 Finally, you should consider adding this line to your profile:
569 This way, if you decide to
579 will work as you expect.
580 .SS "User Environment"
581 Because the environment in which
583 operates may vary for a
586 will look for the environment variable
588 If present, this specifies the name of an additional user profile which
589 should be read. Hence, when a user logs in on a particular machine,
590 this environment variable should be set to refer to a file containing
591 definitions useful for that machine.
595 will attempt to consult a global
600 %etcdir%/mhn.defaults
604 .SS "Syntax of Composition Files"
605 The following is the formal syntax of a
607 \*(lqcomposition file\*(rq.
611 body ::= 1*(content | EOL)
613 content ::= directive | plaintext
615 directive ::= "#" type "/" subtype
616 0*(";" attribute "=" value)
619 [ "[" description "]" ]
620 [ "{" disposition "}" ]
624 | "#@" type "/" subtype
625 0*(";" attribute "=" value)
628 [ "[" description "]" ]
629 [ "{" disposition "}" ]
635 [ "[" description "]" ]
636 [ "{" disposition "}" ]
637 [ "+"folder ] [ 0*msg ]
642 [ "[" description "]" ]
643 [ "{" disposition "}" ]
651 plaintext ::= [ "Content-Description:"
652 description EOL EOL ]
656 | "#<" type "/" subtype
657 0*(";" attribute "=" value)
659 [ "[" description "]" ]
660 [ "{" disposition "}" ]
665 line ::= "##" text EOL
666 -- interpreted as "#"text EOL
672 looks for additional user profile files and mhn.defaults in multiple
673 locations: absolute pathnames are accessed directly, tilde expansion
674 is done on usernames, and files are searched for in the user's
676 directory as specified in their profile. If not found there, the directory
677 .RI \*(lq %etcdir% \*(rq
682 .ta \w'%etcdir%/ExtraBigFileName 'u
683 ^$HOME/\&.mh\(ruprofile~^The user profile
684 ^$MHBUILD~^Additional profile entries
685 ^%etcdir%/mhn.defaults~^System default MIME profile entries
687 .SH "PROFILE COMPONENTS"
691 .ta \w'ExtraBigProfileName 'u
692 ^Path:~^To determine the user's nmh directory
693 ^Current\-Folder:~^To find the default current folder
694 ^mhbuild-compose-<type>*~^Template for composing contents
701 .I "Proposed Standard for Message Encapsulation"
704 .I "The Content-MD5 Header Field"
707 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
710 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
713 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
716 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
719 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
721 .I "Definition of the URL MIME External-Body Access-Type"
727 .RB ` \-norfc934mode '
731 .RB ` \-autoheaderencoding '