1 .TH MHBUILD %manext1% "March 21, 2013" "%nmhversion%"
6 mhbuild \- translate MIME composition draft
12 .RB [ \-auto " | " \-noauto ]
13 .RB [ \-list " | " \-nolist ]
14 .RB [ \-realsize " | " \-norealsize ]
15 .RB [ \-headers " | " \-noheaders ]
16 .RB [ \-directives " | " \-nodirectives ]
17 .RB [ \-rfc934mode " | " \-norfc934mode ]
18 .RB [ \-contentid " | " \-nocontentid ]
19 .RB [ \-verbose " | " \-noverbose ]
20 .RB [ \-check " | " \-nocheck ]
21 .RB [ \-headerencoding
22 .IR encoding\-algorithm
23 .RB " | " \-autoheaderencoding ]
31 command will translate a MIME composition draft into
35 creates multi-media messages as specified in RFC 2045
36 to RFC 2049. This includes the encoding of message headers as specified
39 If you specify the name of the composition file as \*(lq-\*(rq,
42 will accept the composition draft on the standard
43 input. If the translation of this input is successful,
45 will output the new MIME message to the standard output. This argument
46 must be the last argument on the command line.
48 Otherwise if the file argument to
50 is the name of a valid
51 composition file, and the translation is successful,
53 will replace the original file with the new MIME message. It will rename
54 the original file to start with the \*(lq,\*(rq character and end with the
55 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
56 it will be renamed to \*(lq,draft.orig\*(rq. This allows you to easily
60 .SS "Listing the Contents"
65 to list the table of contents associated with the MIME message that is created.
70 that a one-line banner should be displayed above the listing. The
74 to evaluate the \*(lqnative\*(rq
75 (decoded) format of each content prior to listing. This provides an
76 accurate count at the expense of a small delay. If the
79 is present, then the listing will show any \*(lqextra\*(rq information
80 that is present in the message, such as comments in the
81 \*(lqContent-Type\*(rq header.
82 .SS "Translating the Composition File"
84 is essentially a filter to aid in the composition of MIME
89 \*(lqcomposition file\*(rq
90 into a valid MIME message. A
92 \*(lqcomposition file\*(rq
93 is just a file containing plain text that is interspersed
96 directives. When this file is processed
99 the various directives will be expanded to the
100 appropriate content, and will be encoded according to the MIME standards.
101 The resulting MIME message can then be sent by electronic mail.
103 The formal syntax for a
105 composition file is defined at the
106 end of this document, but the ideas behind this format are not complex.
107 Basically, the body contains one or more contents. A content consists of
108 either a directive, indicated with a \*(lq#\*(rq as the first character
109 of a line; or, plaintext (one or more lines of text). The continuation
110 character, \*(lq\\\*(lq, may be used to enter a single directive on more
116 /home/foobar/junk/picture.png
120 There are five kinds of directives: \*(lqtype\*(rq directives, which
121 name the type and subtype of the content; \*(lqexternal-type\*(rq
122 directives, which also name the type and subtype of the content; the
123 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
124 more messages; the \*(lqbegin\*(rq directive (#begin), which is
125 used to create a multipart content; and the \*(lqon/off/pop\*(rq
126 directives (#on, #off, #pop) which control whether any other
127 directives are honored at all.
131 switch allows control over whether mhbuild will honor any of the
132 \*(lq#\*(rq-directives. This can also be affected with the #on or
133 #off directives, and #pop, which restores the state of processing to
134 that preceding the most recent #on or #off. (The #on, #off, and #pop
135 directives are always honored, of course.) This allows inclusion of
136 plain text which looks like mhbuild directives, without causing
143 printf("Hello, World!);
148 Currently the stack depth for the #on/off/pop directives is 32.
150 The \*(lqtype\*(rq directive is used to directly specify the type and
151 subtype of a content. You may only specify discrete types in this manner
152 (can't specify the types multipart or message with this directive).
153 You may optionally specify the name of a file containing the contents
154 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
155 \*(lq|\*(rq character, then it represents a command to execute whose
156 output is captured accordingly.
161 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
165 If a filename is not given,
167 will look for information in the
168 user's profile to determine how the different contents should be composed.
169 This is accomplished by consulting a composition string, and executing
172 with the standard output set to the content.
177 will echo any commands that are used to create contents in this way.
179 The composition string may contain the following escapes:
184 %a Insert parameters from directive
185 %f Insert filename containing content
186 %F %f, and stdout is not re-directed
187 %s Insert content subtype
188 %% Insert character %
194 will look for an entry of the form:
197 mhbuild-compose-<type>/<subtype>
200 to determine the command to use to compose the content. If this isn't
203 will look for an entry of the form:
206 mhbuild-compose-<type>
209 to determine the composition command. If this isn't found,
213 An example entry might be:
216 mhbuild-compose-audio/basic: record | raw2audio -F
219 Because commands like these will vary, depending on the display
220 environment used for login, composition strings for different
221 contents should probably be put in the file specified by the
223 environment variable, instead of directly in your
226 The \*(lqexternal-type\*(rq directives are used to provide a MIME
227 reference to a content, rather than enclosing the contents itself
228 (for instance, by specifying an ftp site). Hence, instead of
229 providing a filename as with the type directives, external-parameters
230 are supplied. These look like regular parameters, so they must be
231 separated accordingly. For example,
235 #@application/octet-stream; \\
237 conversions=compress \\
238 [this is the nmh distribution] \\
239 {attachment; filename="nmh.tar.gz"} \\
240 name="nmh.tar.gz"; \\
241 directory="/pub/nmh"; \\
242 site="ftp.math.gatech.edu"; \\
243 access-type=anon-ftp; \\
248 You must give a description string to separate the content parameters
249 from the external-parameters (although this string may be empty).
250 This description string is specified by enclosing it within
251 \*(lq[]\*(rq. A disposition string, to appear in a
252 \*(lqContent-Disposition\*(rq header, may appear in the optional
255 These parameters are of the form:
259 .ta \w'access-type= 'u
260 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
262 permission= read-only or read-write
264 directory= directoryname (optional)
265 mode= usually \fIascii\fR or \fIimage\fR (optional)
266 size= number of octets
268 subject= subject to send
269 body= command to send for retrieval
274 A mimimum \*(lqexternal\-type\*(rq directive for the
281 #@application/octet-stream [] access-type=url; \\
282 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
286 Any long URLs will be wrapped according to RFC 2017 rules.
288 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
289 group of messages to include. You may optionally specify the name of
290 the folder and which messages are to be forwarded. If a folder is not
291 given, it defaults to the current folder. Similarly, if a message is not
292 given, it defaults to the current message. Hence, the message directive
295 command, except that the former uses
296 the MIME rules for encapsulation rather than those specified in RFC 934.
301 #forw +inbox 42 43 99
305 If you include a single message, it will be included directly as a content
306 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
309 will add a content of type \*(lqmultipart/digest\*(rq
310 and include each message as a subpart of this content.
312 If you are using this directive to include more than one message, you
315 switch. This switch will indicate that
317 should attempt to utilize the MIME encapsulation rules
318 in such a way that the \*(lqmultipart/digest\*(rq that is created
319 is (mostly) compatible with the encapsulation specified in RFC 934.
320 If given, then RFC 934 compliant user-agents should be able to burst the
321 message on reception\0--\0providing that the messages being encapsulated
322 do not contain encapsulated messages themselves. The drawback of this
323 approach is that the encapsulations are generated by placing an extra
324 newline at the end of the body of each message.
326 The \*(lqbegin\*(rq directive is used to create a multipart content.
327 When using the \*(lqbegin\*(rq directive, you must specify at least one
328 content between the begin and end pairs.
333 This will be a multipart with only one part.
338 If you use multiple directives in a composition draft,
341 automatically encapsulate them inside a multipart content. Therefore the
342 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
343 multiparts, or create a multipart message containing only one part.
345 For all of these directives, the user may include a brief description
346 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
347 character. This description will be copied into the
348 \*(lqContent-Description\*(rq header when the directive is processed.
352 #forw [important mail from Bob] +bob 1 2 3 4 5
356 Similarly, a disposition string may optionally be provided between
357 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
358 \*(lqContent-Disposition\*(rq header when the directive is processed.
359 If a disposition string is provided that does not contain a filename
360 parameter, and a filename is provided in the directive, it will be
361 added to the \*(lqContent-Disposition\*(rq header. For example, the
366 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
370 creates these message part headers:
374 Content-Type: text/plain; charset="iso-8859-1"
375 Content-Disposition: attachment; filename="summary.txt"
381 will generate a unique \*(lqContent-ID:\*(rq for each directive,
382 corresponding to each message part; however, the user may override
383 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
386 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
387 even in the top level of the message.
389 In addition to the various directives, plaintext can be present.
390 Plaintext is gathered, until a directive is found or the draft is
391 exhausted, and this is made to form a text content. If the plaintext
392 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
396 ##when sent, this line will start with only one #
399 If you want to end the plaintext prior to a directive, e.g., to have two
400 plaintext contents adjacent, simply insert a line containing a single
401 \*(lq#\*(rq character, e.g.,
405 this is the first content
407 and this is the second
411 Finally, if the plaintext starts with a line of the form:
414 Content-Description: text
417 then this will be used to describe the plaintext content.
418 You MUST follow this line with a blank line before starting
421 By default, plaintext is captured as a text/plain content. You can
422 override this by starting the plaintext with \*(lq#<\*(rq followed by
423 a content-type specification. For example, e.g.,
428 this content will be tagged as text/enriched
430 and this content will be tagged as text/plain
432 #<application/x-patch [this is a patch]
433 and this content will be tagged as application/x-patch
437 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
438 content-description must be on the same line which identifies the content
439 type of the plaintext.
441 When composing a text content, you may indicate the relevant character
442 set by adding the \*(lqcharset\*(rq parameter to the directive.
445 #<text/plain; charset=iso-8859-5
448 If a text content contains any 8\-bit characters (characters with the
449 high bit set) and the character set is not specified as above, then
451 will assume the character set is of the type given by the
452 environment variable MM_CHARSET. If this environment variable is not
453 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
455 If a text content contains only 7\-bit characters and the character set
456 is not specified as above, then the character set will be labeled as
461 switch will indicate which algorithm to use when encoding any message headers
462 that contain 8\-bit characters. The valid arguments are
464 for based\-64 encoding and
466 for quoted\-printable encoding. The
467 .B \-autoheaderencoding
470 to automatically pick the algorithm that results in a shorter encoded string.
472 Putting this all together,
473 here is an example of a more complicated message draft. The
474 following draft will expand into a multipart/mixed message
475 containing five parts:
479 To: nobody@nowhere.org
481 Subject: Look and listen to me!
483 The first part will be text/plain
485 The second part will be text/enriched
487 This third part will be text/plain
488 #audio/basic [silly giggle] \\
489 |raw2audio -F < /usr/lib/sounds/giggle.au
490 #image/gif [photo of foobar] \\
491 /home/foobar/lib/picture.gif
494 .SS "Integrity Check"
499 switch, then it will also associate an integrity check with each
500 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
501 the content, along with the md5 sum of the unencoded contents, per RFC
502 1864. This may be used by the receiver of the message to verify that
503 the contents of the message were not changed in transport.
504 .SS "Transfer Encodings"
507 constructs the new MIME message by parsing directives,
508 including files, etc., it scans the contents of the message to determine
509 which transfer encoding to use. It will check for 8bit data, long lines,
510 spaces at the end of lines, and clashes with multipart boundaries. It will
511 then choose a transfer encoding appropriate for each content type.
513 If an integrity check is being associated with each content by using
518 will encode each content with
519 a transfer encoding, even it the content contains only 7\-bit data. This
520 is to increase the likelihood that the content is not changed while in
522 .SS "Invoking mhbuild"
528 command will expect the body of the draft to be formatted as an
530 composition file. Once you have composed this input file
531 using a command such as
538 at the \*(lqWhat now\*(rq prompt with
544 prior to sending the draft. This will cause
548 to translate the composition file into MIME format.
550 Normally it is an error to invoke
552 on file that already in MIME format. The
556 to exit without error if the input file already has valid MIME headers.
558 Finally, you should consider adding this line to your profile:
564 This way, if you decide to
574 will work as you expect.
578 switch is intended to be used by
580 It will cause mhbuild to not generate any MIME headers in the composition
581 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
582 will still encode message headers according to RFC 2047.
583 .SS "User Environment"
584 Because the environment in which
586 operates may vary for a
589 will look for the environment variable
591 If present, this specifies the name of an additional user profile which
592 should be read. Hence, when a user logs in on a particular machine,
593 this environment variable should be set to refer to a file containing
594 definitions useful for that machine.
598 will attempt to consult a global
603 %etcdir%/mhn.defaults
607 .SS "Syntax of Composition Files"
608 The following is the formal syntax of a
610 \*(lqcomposition file\*(rq.
614 body ::= 1*(content | EOL)
616 content ::= directive | plaintext
618 directive ::= "#" type "/" subtype
619 0*(";" attribute "=" value)
622 [ "[" description "]" ]
623 [ "{" disposition "}" ]
627 | "#@" type "/" subtype
628 0*(";" attribute "=" value)
631 [ "[" description "]" ]
632 [ "{" disposition "}" ]
638 [ "[" description "]" ]
639 [ "{" disposition "}" ]
640 [ "+"folder ] [ 0*msg ]
645 [ "[" description "]" ]
646 [ "{" disposition "}" ]
654 plaintext ::= [ "Content-Description:"
655 description EOL EOL ]
659 | "#<" type "/" subtype
660 0*(";" attribute "=" value)
662 [ "[" description "]" ]
663 [ "{" disposition "}" ]
668 line ::= "##" text EOL
669 -- interpreted as "#"text EOL
675 looks for additional user profile files and mhn.defaults in multiple
676 locations: absolute pathnames are accessed directly, tilde expansion
677 is done on usernames, and files are searched for in the user's
679 directory as specified in their profile. If not found there, the directory
680 .RI \*(lq %etcdir% \*(rq
685 .ta \w'%etcdir%/ExtraBigFileName 'u
686 ^$HOME/\&.mh\(ruprofile~^The user profile
687 ^$MHBUILD~^Additional profile entries
688 ^%etcdir%/mhn.defaults~^System default MIME profile entries
690 .SH "PROFILE COMPONENTS"
694 .ta \w'ExtraBigProfileName 'u
695 ^Path:~^To determine the user's nmh directory
696 ^Current\-Folder:~^To find the default current folder
697 ^mhbuild-compose-<type>*~^Template for composing contents
704 .I "Proposed Standard for Message Encapsulation"
707 .I "The Content-MD5 Header Field"
710 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
713 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
716 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
719 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
722 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
724 .I "Definition of the URL MIME External-Body Access-Type"
730 .RB ` \-norfc934mode '
734 .RB ` \-autoheaderencoding '