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 algorithm that results in a shorter encoded string.
93 .SS "Translating the Composition File"
95 is essentially a filter to aid in the composition of MIME
100 \*(lqcomposition file\*(rq
101 into a valid MIME message. A
103 \*(lqcomposition file\*(rq
104 is just a file containing plain text that is interspersed
107 directives. When this file is processed
110 the various directives will be expanded to the
111 appropriate content, and will be encoded according to the MIME standards.
112 The resulting MIME message can then be sent by electronic mail.
114 The formal syntax for a
116 composition file is defined at the
117 end of this document, but the ideas behind this format are not complex.
118 Basically, the body contains one or more contents. A content consists of
119 either a directive, indicated with a \*(lq#\*(rq as the first character
120 of a line; or, plaintext (one or more lines of text). The continuation
121 character, \*(lq\\\*(lq, may be used to enter a single directive on more
127 /home/foobar/junk/picture.png
131 There are five kinds of directives: \*(lqtype\*(rq directives, which
132 name the type and subtype of the content; \*(lqexternal-type\*(rq
133 directives, which also name the type and subtype of the content; the
134 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
135 more messages; the \*(lqbegin\*(rq directive (#begin), which is
136 used to create a multipart content; and the \*(lqon/off/pop\*(rq
137 directives (#on, #off, #pop) which control whether any other
138 directives are honored at all.
142 switch allows control over whether mhbuild will honor any of the
143 \*(lq#\*(rq-directives. This can also be affected with the #on or
144 #off directives, and #pop, which restores the state of processing to
145 that preceding the most recent #on or #off. (The #on, #off, and #pop
146 directives are always honored, of course.) This allows inclusion of
147 plain text which looks like mhbuild directives, without causing
154 printf("Hello, World!);
159 Currently the stack depth for the #on/off/pop directives is 32.
161 The \*(lqtype\*(rq directive is used to directly specify the type and
162 subtype of a content. You may only specify discrete types in this manner
163 (can't specify the types multipart or message with this directive).
164 You may optionally specify the name of a file containing the contents
165 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
166 \*(lq|\*(rq character, then it represents a command to execute whose
167 output is captured accordingly.
172 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
176 If a filename is not given,
178 will look for information in the
179 user's profile to determine how the different contents should be composed.
180 This is accomplished by consulting a composition string, and executing
183 with the standard output set to the content.
188 will echo any commands that are used to create contents in this way.
190 The composition string may contain the following escapes:
195 %a Insert parameters from directive
196 %f Insert filename containing content
197 %F %f, and stdout is not re-directed
198 %s Insert content subtype
199 %% Insert character %
205 will look for an entry of the form:
208 mhbuild-compose-<type>/<subtype>
211 to determine the command to use to compose the content. If this isn't
214 will look for an entry of the form:
217 mhbuild-compose-<type>
220 to determine the composition command. If this isn't found,
224 An example entry might be:
227 mhbuild-compose-audio/basic: record | raw2audio -F
230 Because commands like these will vary, depending on the display
231 environment used for login, composition strings for different
232 contents should probably be put in the file specified by the
234 environment variable, instead of directly in your
237 The \*(lqexternal-type\*(rq directives are used to provide a MIME
238 reference to a content, rather than enclosing the contents itself
239 (for instance, by specifying an ftp site). Hence, instead of
240 providing a filename as with the type directives, external-parameters
241 are supplied. These look like regular parameters, so they must be
242 separated accordingly. For example,
246 #@application/octet-stream; \\
248 conversions=compress \\
249 [this is the nmh distribution] \\
250 {attachment; filename="nmh.tar.gz"} \\
251 name="nmh.tar.gz"; \\
252 directory="/pub/nmh"; \\
253 site="ftp.math.gatech.edu"; \\
254 access-type=anon-ftp; \\
259 You must give a description string to separate the content parameters
260 from the external-parameters (although this string may be empty).
261 This description string is specified by enclosing it within
262 \*(lq[]\*(rq. A disposition string, to appear in a
263 \*(lqContent-Disposition\*(rq header, may appear in the optional
266 These parameters are of the form:
270 .ta \w'access-type= 'u
271 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
273 permission= read-only or read-write
275 directory= directoryname (optional)
276 mode= usually \fIascii\fR or \fIimage\fR (optional)
277 size= number of octets
279 subject= subject to send
280 body= command to send for retrieval
285 A mimimum \*(lqexternal\-type\*(rq directive for the
292 #@application/octet-stream [] access-type=url; \\
293 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
297 Any long URLs will be wrapped according to RFC 2017 rules.
299 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
300 group of messages to include. You may optionally specify the name of
301 the folder and which messages are to be forwarded. If a folder is not
302 given, it defaults to the current folder. Similarly, if a message is not
303 given, it defaults to the current message. Hence, the message directive
306 command, except that the former uses
307 the MIME rules for encapsulation rather than those specified in RFC 934.
312 #forw +inbox 42 43 99
316 If you include a single message, it will be included directly as a content
317 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
320 will add a content of type \*(lqmultipart/digest\*(rq
321 and include each message as a subpart of this content.
323 If you are using this directive to include more than one message, you
326 switch. This switch will indicate that
328 should attempt to utilize the MIME encapsulation rules
329 in such a way that the \*(lqmultipart/digest\*(rq that is created
330 is (mostly) compatible with the encapsulation specified in RFC 934.
331 If given, then RFC 934 compliant user-agents should be able to burst the
332 message on reception\0--\0providing that the messages being encapsulated
333 do not contain encapsulated messages themselves. The drawback of this
334 approach is that the encapsulations are generated by placing an extra
335 newline at the end of the body of each message.
337 The \*(lqbegin\*(rq directive is used to create a multipart content.
338 When using the \*(lqbegin\*(rq directive, you must specify at least one
339 content between the begin and end pairs.
344 This will be a multipart with only one part.
349 If you use multiple directives in a composition draft,
352 automatically encapsulate them inside a multipart content. Therefore the
353 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
354 multiparts, or create a multipart message containing only one part.
356 For all of these directives, the user may include a brief description
357 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
358 character. This description will be copied into the
359 \*(lqContent-Description\*(rq header when the directive is processed.
363 #forw [important mail from Bob] +bob 1 2 3 4 5
367 Similarly, a disposition string may optionally be provided between
368 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
369 \*(lqContent-Disposition\*(rq header when the directive is processed.
370 If a disposition string is provided that does not contain a filename
371 parameter, and a filename is provided in the directive, it will be
372 added to the \*(lqContent-Disposition\*(rq header. For example, the
377 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
381 creates these message part headers:
385 Content-Type: text/plain; charset="iso-8859-1"
386 Content-Disposition: attachment; filename="summary.txt"
392 will generate a unique \*(lqContent-ID:\*(rq for each directive,
393 corresponding to each message part; however, the user may override
394 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
397 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
398 even in the top level of the message.
400 In addition to the various directives, plaintext can be present.
401 Plaintext is gathered, until a directive is found or the draft is
402 exhausted, and this is made to form a text content. If the plaintext
403 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
407 ##when sent, this line will start with only one #
410 If you want to end the plaintext prior to a directive, e.g., to have two
411 plaintext contents adjacent, simply insert a line containing a single
412 \*(lq#\*(rq character, e.g.,
416 this is the first content
418 and this is the second
422 Finally, if the plaintext starts with a line of the form:
425 Content-Description: text
428 then this will be used to describe the plaintext content.
429 You MUST follow this line with a blank line before starting
432 By default, plaintext is captured as a text/plain content. You can
433 override this by starting the plaintext with \*(lq#<\*(rq followed by
434 a content-type specification. For example, e.g.,
439 this content will be tagged as text/enriched
441 and this content will be tagged as text/plain
443 #<application/x-patch [this is a patch]
444 and this content will be tagged as application/x-patch
448 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
449 content-description must be on the same line which identifies the content
450 type of the plaintext.
452 When composing a text content, you may indicate the relevant character
453 set by adding the \*(lqcharset\*(rq parameter to the directive.
456 #<text/plain; charset=iso-8859-5
459 If a text content contains any 8\-bit characters (characters with the
460 high bit set) and the character set is not specified as above, then
462 will assume the character set is of the type given by the
463 environment variable MM_CHARSET. If this environment variable is not
464 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
466 If a text content contains only 7\-bit characters and the character set
467 is not specified as above, then the character set will be labeled as
470 Putting this all together,
471 here is an example of a more complicated message draft. The
472 following draft will expand into a multipart/mixed message
473 containing five parts:
477 To: nobody@nowhere.org
479 Subject: Look and listen to me!
481 The first part will be text/plain
483 The second part will be text/enriched
485 This third part will be text/plain
486 #audio/basic [silly giggle] \\
487 |raw2audio -F < /usr/lib/sounds/giggle.au
488 #image/gif [photo of foobar] \\
489 /home/foobar/lib/picture.gif
492 .SS "Integrity Check"
497 switch, then it will also associate an integrity check with each
498 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
499 the content, along with the md5 sum of the unencoded contents, per RFC
500 1864. This may be used by the receiver of the message to verify that
501 the contents of the message were not changed in transport.
502 .SS "Transfer Encodings"
505 constructs the new MIME message by parsing directives,
506 including files, etc., it scans the contents of the message to determine
507 which transfer encoding to use. It will check for 8bit data, long lines,
508 spaces at the end of lines, and clashes with multipart boundaries. It will
509 then choose a transfer encoding appropriate for each content type.
511 If an integrity check is being associated with each content by using
516 will encode each content with
517 a transfer encoding, even it the content contains only 7\-bit data. This
518 is to increase the likelihood that the content is not changed while in
520 .SS "Invoking mhbuild"
526 command will expect the body of the draft to be formatted as an
528 composition file. Once you have composed this input file
529 using a command such as
536 at the \*(lqWhat now\*(rq prompt with
542 prior to sending the draft. This will cause
546 to translate the composition file into MIME format.
548 It is also possible to have the
552 automatically when a message is sent. To do this, you must add the line
562 Finally, you should consider adding this line to your profile:
568 This way, if you decide to
578 will work as you expect.
579 .SS "User Environment"
580 Because the environment in which
582 operates may vary for a
585 will look for the environment variable
587 If present, this specifies the name of an additional user profile which
588 should be read. Hence, when a user logs in on a particular machine,
589 this environment variable should be set to refer to a file containing
590 definitions useful for that machine.
594 will attempt to consult a global
599 %etcdir%/mhn.defaults
603 .SS "Syntax of Composition Files"
604 The following is the formal syntax of a
606 \*(lqcomposition file\*(rq.
610 body ::= 1*(content | EOL)
612 content ::= directive | plaintext
614 directive ::= "#" type "/" subtype
615 0*(";" attribute "=" value)
618 [ "[" description "]" ]
619 [ "{" disposition "}" ]
623 | "#@" type "/" subtype
624 0*(";" attribute "=" value)
627 [ "[" description "]" ]
628 [ "{" disposition "}" ]
634 [ "[" description "]" ]
635 [ "{" disposition "}" ]
636 [ "+"folder ] [ 0*msg ]
641 [ "[" description "]" ]
642 [ "{" disposition "}" ]
650 plaintext ::= [ "Content-Description:"
651 description EOL EOL ]
655 | "#<" type "/" subtype
656 0*(";" attribute "=" value)
658 [ "[" description "]" ]
659 [ "{" disposition "}" ]
664 line ::= "##" text EOL
665 -- interpreted as "#"text EOL
671 looks for additional user profile files and mhn.defaults in multiple
672 locations: absolute pathnames are accessed directly, tilde expansion
673 is done on usernames, and files are searched for in the user's
675 directory as specified in their profile. If not found there, the directory
676 .RI \*(lq %etcdir% \*(rq
681 .ta \w'%etcdir%/ExtraBigFileName 'u
682 ^$HOME/\&.mh\(ruprofile~^The user profile
683 ^$MHBUILD~^Additional profile entries
684 ^%etcdir%/mhn.defaults~^System default MIME profile entries
686 .SH "PROFILE COMPONENTS"
690 .ta \w'ExtraBigProfileName 'u
691 ^Path:~^To determine the user's nmh directory
692 ^Current\-Folder:~^To find the default current folder
693 ^mhbuild-compose-<type>*~^Template for composing contents
700 .I "Proposed Standard for Message Encapsulation"
703 .I "The Content-MD5 Header Field"
706 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
709 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
712 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
715 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
718 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
720 .I "Definition of the URL MIME External-Body Access-Type"
726 .RB ` \-norfc934mode '
730 .RB ` \-autoheaderencoding '