1 .TH MHBUILD %manext1% "January 23, 2014" "%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 "Simplified Attachment Interface"
83 For users who wish to simply attach files to text content,
85 will scan the composition file for \*(lqAttach\*(rq headers. An
86 \*(lqAttach\*(rq header contains a filename that will be appended to the
87 message using normal MIME encapsulation rules. One filename is allowed
88 per \*(lqAttach\*(rq header, but multiple \*(lqAttach\*(rq headers are
89 allowed ber composition file.
91 These files will be appended after any other MIME content, including any
94 directives (see below). See
97 .SS "Translating the Composition File"
99 is essentially a filter to aid in the composition of MIME
104 \*(lqcomposition file\*(rq
105 into a valid MIME message. A
107 \*(lqcomposition file\*(rq
108 is just a file containing plain text that is interspersed
111 directives. When this file is processed
114 the various directives will be expanded to the
115 appropriate content, and will be encoded according to the MIME standards.
116 The resulting MIME message can then be sent by electronic mail.
118 The formal syntax for a
120 composition file is defined at the
121 end of this document, but the ideas behind this format are not complex.
122 Basically, the body contains one or more contents. A content consists of
123 either a directive, indicated with a \*(lq#\*(rq as the first character
124 of a line; or, plaintext (one or more lines of text). The continuation
125 character, \*(lq\\\*(lq, may be used to enter a single directive on more
131 /home/foobar/junk/picture.png
135 There are five kinds of directives: \*(lqtype\*(rq directives, which
136 name the type and subtype of the content; \*(lqexternal-type\*(rq
137 directives, which also name the type and subtype of the content; the
138 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
139 more messages; the \*(lqbegin\*(rq directive (#begin), which is
140 used to create a multipart content; and the \*(lqon/off/pop\*(rq
141 directives (#on, #off, #pop) which control whether any other
142 directives are honored at all.
146 switch allows control over whether mhbuild will honor any of the
147 \*(lq#\*(rq-directives. This can also be affected with the #on or
148 #off directives, and #pop, which restores the state of processing to
149 that preceding the most recent #on or #off. (The #on, #off, and #pop
150 directives are always honored, of course.) This allows inclusion of
151 plain text which looks like mhbuild directives, without causing
158 printf("Hello, World!);
163 Currently the stack depth for the #on/off/pop directives is 32.
165 The \*(lqtype\*(rq directive is used to directly specify the type and
166 subtype of a content. You may only specify discrete types in this manner
167 (can't specify the types multipart or message with this directive).
168 You may optionally specify the name of a file containing the contents
169 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
170 \*(lq|\*(rq character, then it represents a command to execute whose
171 output is captured accordingly.
176 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
180 If a filename is not given,
182 will look for information in the
183 user's profile to determine how the different contents should be composed.
184 This is accomplished by consulting a composition string, and executing
187 with the standard output set to the content.
192 will echo any commands that are used to create contents in this way.
194 The composition string may contain the following escapes:
199 %a Insert parameters from directive
200 %f Insert filename containing content
201 %F %f, and stdout is not re-directed
202 %s Insert content subtype
203 %% Insert character %
209 will look for an entry of the form:
212 mhbuild-compose-<type>/<subtype>
215 to determine the command to use to compose the content. If this isn't
218 will look for an entry of the form:
221 mhbuild-compose-<type>
224 to determine the composition command. If this isn't found,
228 An example entry might be:
231 mhbuild-compose-audio/basic: record | raw2audio -F
234 Because commands like these will vary, depending on the display
235 environment used for login, composition strings for different
236 contents should probably be put in the file specified by the
238 environment variable, instead of directly in your
241 The \*(lqexternal-type\*(rq directives are used to provide a MIME
242 reference to a content, rather than enclosing the contents itself
243 (for instance, by specifying an ftp site). Hence, instead of
244 providing a filename as with the type directives, external-parameters
245 are supplied. These look like regular parameters, so they must be
246 separated accordingly. For example,
250 #@application/octet-stream; \\
252 conversions=compress \\
253 [this is the nmh distribution] \\
254 {attachment; filename="nmh.tar.gz"} \\
255 name="nmh.tar.gz"; \\
256 directory="/pub/nmh"; \\
257 site="ftp.math.gatech.edu"; \\
258 access-type=anon-ftp; \\
263 You must give a description string to separate the content parameters
264 from the external-parameters (although this string may be empty).
265 This description string is specified by enclosing it within
266 \*(lq[]\*(rq. A disposition string, to appear in a
267 \*(lqContent-Disposition\*(rq header, may appear in the optional
270 These parameters are of the form:
274 .ta \w'access-type= 'u
275 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
277 permission= read-only or read-write
279 directory= directoryname (optional)
280 mode= usually \fIascii\fR or \fIimage\fR (optional)
281 size= number of octets
283 subject= subject to send
284 body= command to send for retrieval
289 A mimimum \*(lqexternal\-type\*(rq directive for the
296 #@application/octet-stream [] access-type=url; \\
297 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
301 Any long URLs will be wrapped according to RFC 2017 rules.
303 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
304 group of messages to include. You may optionally specify the name of
305 the folder and which messages are to be forwarded. If a folder is not
306 given, it defaults to the current folder. Similarly, if a message is not
307 given, it defaults to the current message. Hence, the message directive
310 command, except that the former uses
311 the MIME rules for encapsulation rather than those specified in RFC 934.
316 #forw +inbox 42 43 99
320 If you include a single message, it will be included directly as a content
321 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
324 will add a content of type \*(lqmultipart/digest\*(rq
325 and include each message as a subpart of this content.
327 If you are using this directive to include more than one message, you
330 switch. This switch will indicate that
332 should attempt to utilize the MIME encapsulation rules
333 in such a way that the \*(lqmultipart/digest\*(rq that is created
334 is (mostly) compatible with the encapsulation specified in RFC 934.
335 If given, then RFC 934 compliant user-agents should be able to burst the
336 message on reception\0--\0providing that the messages being encapsulated
337 do not contain encapsulated messages themselves. The drawback of this
338 approach is that the encapsulations are generated by placing an extra
339 newline at the end of the body of each message.
341 The \*(lqbegin\*(rq directive is used to create a multipart content.
342 When using the \*(lqbegin\*(rq directive, you must specify at least one
343 content between the begin and end pairs.
348 This will be a multipart with only one part.
353 If you use multiple directives in a composition draft,
356 automatically encapsulate them inside a multipart content. Therefore the
357 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
358 multiparts, or create a multipart message containing only one part.
360 For all of these directives, the user may include a brief description
361 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
362 character. This description will be copied into the
363 \*(lqContent-Description\*(rq header when the directive is processed.
367 #forw [important mail from Bob] +bob 1 2 3 4 5
371 Similarly, a disposition string may optionally be provided between
372 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
373 \*(lqContent-Disposition\*(rq header when the directive is processed.
374 If a disposition string is provided that does not contain a filename
375 parameter, and a filename is provided in the directive, it will be
376 added to the \*(lqContent-Disposition\*(rq header. For example, the
381 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
385 creates these message part headers:
389 Content-Type: text/plain; charset="iso-8859-1"
390 Content-Disposition: attachment; filename="summary.txt"
396 will generate a unique \*(lqContent-ID:\*(rq for each directive,
397 corresponding to each message part; however, the user may override
398 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
401 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
402 even in the top level of the message.
404 In addition to the various directives, plaintext can be present.
405 Plaintext is gathered, until a directive is found or the draft is
406 exhausted, and this is made to form a text content. If the plaintext
407 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
411 ##when sent, this line will start with only one #
414 If you want to end the plaintext prior to a directive, e.g., to have two
415 plaintext contents adjacent, simply insert a line containing a single
416 \*(lq#\*(rq character, e.g.,
420 this is the first content
422 and this is the second
426 Finally, if the plaintext starts with a line of the form:
429 Content-Description: text
432 then this will be used to describe the plaintext content.
433 You MUST follow this line with a blank line before starting
436 By default, plaintext is captured as a text/plain content. You can
437 override this by starting the plaintext with \*(lq#<\*(rq followed by
438 a content-type specification. For example, e.g.,
443 this content will be tagged as text/enriched
445 and this content will be tagged as text/plain
447 #<application/x-patch [this is a patch]
448 and this content will be tagged as application/x-patch
452 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
453 content-description must be on the same line which identifies the content
454 type of the plaintext.
456 When composing a text content, you may indicate the relevant character
457 set by adding the \*(lqcharset\*(rq parameter to the directive.
460 #<text/plain; charset=iso-8859-5
463 If a text content contains any 8\-bit characters (characters with the
464 high bit set) and the character set is not specified as above, then
466 will assume the character set is of the type given by the
469 environment variables. If these environment variables are not
470 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
472 If a text content contains only 7\-bit characters and the character set
473 is not specified as above, then the character set will be labeled as
478 switch will indicate which algorithm to use when encoding any message headers
479 that contain 8\-bit characters. The valid arguments are
481 for based\-64 encoding and
483 for quoted\-printable encoding. The
484 .B \-autoheaderencoding
487 to automatically pick the algorithm that results in a shorter encoded string.
489 Putting this all together,
490 here is an example of a more complicated message draft. The
491 following draft will expand into a multipart/mixed message
492 containing five parts:
496 To: nobody@nowhere.org
498 Subject: Look and listen to me!
500 The first part will be text/plain
502 The second part will be text/enriched
504 This third part will be text/plain
505 #audio/basic [silly giggle] \\
506 |raw2audio -F < /usr/lib/sounds/giggle.au
507 #image/gif [photo of foobar] \\
508 /home/foobar/lib/picture.gif
511 .SS "Integrity Check"
516 switch, then it will also associate an integrity check with each
517 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
518 the content, along with the md5 sum of the unencoded contents, per RFC
519 1864. This may be used by the receiver of the message to verify that
520 the contents of the message were not changed in transport.
521 .SS "Transfer Encodings"
524 constructs the new MIME message by parsing directives,
525 including files, etc., it scans the contents of the message to determine
526 which transfer encoding to use. It will check for 8bit data, long lines,
527 spaces at the end of lines, and clashes with multipart boundaries. It will
528 then choose a transfer encoding appropriate for each content type.
530 If an integrity check is being associated with each content by using
535 will encode each content with
536 a transfer encoding, even it the content contains only 7\-bit data. This
537 is to increase the likelihood that the content is not changed while in
539 .SS "Invoking mhbuild"
545 command will expect the body of the draft to be formatted as an
547 composition file. Once you have composed this input file
548 using a command such as
555 at the \*(lqWhat now\*(rq prompt with
561 prior to sending the draft. This will cause
565 to translate the composition file into MIME format.
567 Normally it is an error to invoke
569 on file that already in MIME format. The
573 to exit without error if the input file already has valid MIME headers.
580 Finally, you should consider adding this line to your profile:
586 This way, if you decide to
596 will work as you expect.
600 switch is intended to be used by
602 It will cause mhbuild to not generate any MIME headers in the composition
603 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
604 will still encode message headers according to RFC 2047.
605 .SS "User Environment"
606 Because the environment in which
608 operates may vary for a
611 will look for the environment variable
613 If present, this specifies the name of an additional user profile which
614 should be read. Hence, when a user logs in on a particular machine,
615 this environment variable should be set to refer to a file containing
616 definitions useful for that machine.
620 will attempt to consult a global
625 %etcdir%/mhn.defaults
629 .SS "Syntax of Composition Files"
630 The following is the formal syntax of a
632 \*(lqcomposition file\*(rq.
636 body ::= 1*(content | EOL)
638 content ::= directive | plaintext
640 directive ::= "#" type "/" subtype
641 0*(";" attribute "=" value)
644 [ "[" description "]" ]
645 [ "{" disposition "}" ]
649 | "#@" type "/" subtype
650 0*(";" attribute "=" value)
653 [ "[" description "]" ]
654 [ "{" disposition "}" ]
660 [ "[" description "]" ]
661 [ "{" disposition "}" ]
662 [ "+"folder ] [ 0*msg ]
667 [ "[" description "]" ]
668 [ "{" disposition "}" ]
676 plaintext ::= [ "Content-Description:"
677 description EOL EOL ]
681 | "#<" type "/" subtype
682 0*(";" attribute "=" value)
684 [ "[" description "]" ]
685 [ "{" disposition "}" ]
690 line ::= "##" text EOL
691 -- interpreted as "#"text EOL
697 looks for additional user profile files and mhn.defaults in multiple
698 locations: absolute pathnames are accessed directly, tilde expansion
699 is done on usernames, and files are searched for in the user's
701 directory as specified in their profile. If not found there, the directory
702 .RI \*(lq %etcdir% \*(rq
707 .ta \w'%etcdir%/ExtraBigFileName 'u
708 ^$HOME/\&.mh\(ruprofile~^The user profile
709 ^$MHBUILD~^Additional profile entries
710 ^%etcdir%/mhn.defaults~^System default MIME profile entries
712 .SH "PROFILE COMPONENTS"
716 .ta \w'ExtraBigProfileName 'u
717 ^Path:~^To determine the user's nmh directory
718 ^Current\-Folder:~^To find the default current folder
719 ^mhbuild-compose-<type>*~^Template for composing contents
726 .I "Proposed Standard for Message Encapsulation"
729 .I "The Content-MD5 Header Field"
732 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
735 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
738 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
741 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
744 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
746 .I "Definition of the URL MIME External-Body Access-Type"
752 .RB ` \-norfc934mode '
756 .RB ` \-autoheaderencoding '