1 .TH MHBUILD %manext1% "December 14, 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 [ \-disposition " | " \-nodisposition ]
21 .RB [ \-check " | " \-nocheck ]
22 .RB [ \-headerencoding
23 .IR encoding\-algorithm
24 .RB " | " \-autoheaderencoding ]
34 command will translate a MIME composition draft into
38 creates multi-media messages as specified in RFC 2045
39 to RFC 2049. This includes the encoding of message headers as specified
40 by RFC 2047, and the encoding of MIME parameters as specified in RFC 2231.
42 If you specify the name of the composition file as \*(lq-\*(rq,
45 will accept the composition draft on the standard
46 input. If the translation of this input is successful,
48 will output the new MIME message to the standard output. This argument
49 must be the last argument on the command line.
51 Otherwise if the file argument to
53 is the name of a valid
54 composition file, and the translation is successful,
56 will replace the original file with the new MIME message. It will rename
57 the original file to start with the \*(lq,\*(rq character and end with the
58 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
59 it will be renamed to \*(lq,draft.orig\*(rq. This allows you to easily
63 .SS "Listing the Contents"
68 to list the table of contents associated with the MIME message that is created.
73 that a one-line banner should be displayed above the listing. The
77 to evaluate the \*(lqnative\*(rq
78 (decoded) format of each content prior to listing. This provides an
79 accurate count at the expense of a small delay. If the
82 is present, then the listing will show any \*(lqextra\*(rq information
83 that is present in the message, such as comments in the
84 \*(lqContent-Type\*(rq header.
88 switch is present, then the listing will show any relevant information from
89 the \*(lqContent-Disposition\*(rq header.
90 .SS "Simplified Attachment Interface"
91 For users who wish to simply attach files to text content,
93 will scan the composition file for \*(lqAttach\*(rq headers. An
94 \*(lqAttach\*(rq header contains a filename that will be appended to the
95 message using normal MIME encapsulation rules. One filename is allowed
96 per \*(lqAttach\*(rq header, but multiple \*(lqAttach\*(rq headers are
97 allowed ber composition file.
99 These files will be appended after any other MIME content, including any
102 directives (see below). See
106 By default, the Content-Disposition will be \*(lqattachment\*(rq.
108 looks for user profile and mhn.defaults entries of the form
111 mhbuild-disposition-<type>/<subtype>
115 mhbuild-disposition-<type>
118 to supply the disposition value. The only supported values are
122 .SS "Convert Interface"
124 The \*(lqconvert\*(rq interface is a powerful mechanism that supports
125 replying to MIME messages. These placeholders are used in the following
130 external program, and any fixed arguments, to convert content, such as
131 from a request to a reply
133 arguments to pass from
138 full path of message being replied to
141 The convert support is based on pseudoheaders of the form
144 Nmh-mhbuild-file-TYPE: FILE
145 Nmh-mhbuild-args-TYPE: ARGSTRING
148 in the draft. For each such pseudoheader, mhbuild looks in the
149 profile and mhn.defaults for this corresponding TYPE entry to find the
150 converter that supports it:
153 .RI mhbuild-convert- TYPE :
157 It's a fatal error if no such entry is found for TYPE. An empty
161 mhbuild-convert-text/html:
164 excludes parts of that TYPE from the draft. The mhn.defaults file
166 .B mhbuild-convert-text/html
168 .BR mhbuild-convert-text/plain
169 entries. Profile entries can be used to override corresponding
170 mhn.defaults entries, as usual.
178 .I CONVERTER ARGSTRING
179 on the content of the part.
183 that has no corresponding TYPE entry in the profile or mhn.defaults is
184 excluded from the draft; the user can include them using mhbuild
188 inserts Nmh-mhbuild-text/html: and Nmh-mhbuild-text/plain:
189 pseudoheaders in every draft. The user can prevent insertion of
190 content parts of either of those types by putting corresponding empty
191 entries in their profile.
193 Only the highest precedence alternative with a supported
195 of a multipart/alternative part is used.
197 mhn.defaults.sh selects the text/html-to-text/plain converter at
198 install time. It includes
204 in the pipeline only if found.
206 Some content types require the addition of parameters to the
207 Content-Type header, such as
209 for text/calendar. mhbuild looks for a Content-Type header, followed
210 by a blank line, at the beginning of the converter output. If one is
211 found, it is used for the corresponding part in the reply draft.
213 The \*(lqconvert\*(rq interface doesn't support different
215 or different converters for different parts of the same
217 That would require associating parts by part number with the
219 or converters. Instead, that can be done (currently, without using
220 the convert support), with
222 directives as described below, e.g.,
225 #text/html; charset=utf-8 *8bit | mhstore -noverbose -part 42.7 -outfile - | w3m -dump -cols 64 -T text/html -O utf-8
230 pseudoheaders and mhbuild directives is to insert the directives before
232 is run, which is typically done by entering
234 at the \*(lqWhat now?\*(rq prompt, or with an
238 These (optional) setup steps can make the convert support
243 program is installed on your system, it will be set by default
244 (in mhn.defaults) to filter the converter output. It helps to
247 environment variable, as described in its man page.
249 Add this line to your profile:
253 mhbuild-next: $EDITOR
258 assuming that your EDTIOR environment variable is set; if not, replace
259 $EDITOR with the name of your editor. Without that profile entry, a
260 response of \*(lqe[dit]\*(rq at the What now? prompt will require
261 specification of your editor if an
268 source the Bourne-shell compatible functions in
269 .IR %docdir%/contrib/replaliases .
271 That script also sets the
273 environment variable if it was not set.
276 .SS "Translating the Composition File"
278 is essentially a filter to aid in the composition of MIME
283 \*(lqcomposition file\*(rq
284 into a valid MIME message. A
286 \*(lqcomposition file\*(rq
287 is just a file containing plain text that is interspersed
290 directives. When this file is processed
293 the various directives will be expanded to the
294 appropriate content, and will be encoded according to the MIME standards.
295 The resulting MIME message can then be sent by electronic mail.
297 The formal syntax for a
299 composition file is defined at the
300 end of this document, but the ideas behind this format are not complex.
301 Basically, the body contains one or more contents. A content consists of
302 either a directive, indicated with a \*(lq#\*(rq as the first character
303 of a line; or, plaintext (one or more lines of text). The continuation
304 character, \*(lq\\\*(lq, may be used to enter a single directive on more
310 /home/foobar/junk/picture.png
314 There are five kinds of directives: \*(lqtype\*(rq directives, which
315 name the type and subtype of the content; \*(lqexternal-type\*(rq
316 directives, which also name the type and subtype of the content; the
317 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
318 more messages; the \*(lqbegin\*(rq directive (#begin), which is
319 used to create a multipart content; and the \*(lqon/off/pop\*(rq
320 directives (#on, #off, #pop) which control whether any other
321 directives are honored at all.
325 switch allows control over whether mhbuild will honor any of the
326 \*(lq#\*(rq-directives. This can also be affected with the #on or
327 #off directives, and #pop, which restores the state of processing to
328 that preceding the most recent #on or #off. (The #on, #off, and #pop
329 directives are always honored, of course.) This allows inclusion of
330 plain text which looks like mhbuild directives, without causing
337 printf("Hello, World!");
342 Currently the stack depth for the #on/off/pop directives is 32.
344 The \*(lqtype\*(rq directive is used to directly specify the type and
345 subtype of a content. You may only specify discrete types in this manner
346 (can't specify the types multipart or message with this directive).
347 You may optionally specify the name of a file containing the contents
348 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
349 \*(lq|\*(rq character, then it represents a command to execute whose
350 output is captured accordingly.
355 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
359 If a filename is not given,
361 will look for information in the
362 user's profile to determine how the different contents should be composed.
363 This is accomplished by consulting a composition string, and executing
366 with the standard output set to the content.
371 will echo any commands that are used to create contents in this way.
373 The composition string may contain the following escapes:
378 %a Insert parameters from directive
379 %f Insert filename containing content
380 %F %f, and stdout is not re-directed
381 %s Insert content subtype
382 %% Insert character %
388 will look for an entry of the form:
391 mhbuild-compose-<type>/<subtype>
394 to determine the command to use to compose the content. If this isn't
397 will look for an entry of the form:
400 mhbuild-compose-<type>
403 to determine the composition command. If this isn't found,
407 An example entry might be:
410 mhbuild-compose-audio/basic: record | raw2audio -F
413 Because commands like these will vary, depending on the display
414 environment used for login, composition strings for different
415 contents should probably be put in the file specified by the
417 environment variable, instead of directly in your
420 The \*(lqexternal-type\*(rq directives are used to provide a MIME
421 reference to a content, rather than enclosing the contents itself
422 (for instance, by specifying an ftp site). Hence, instead of
423 providing a filename as with the type directives, external-parameters
424 are supplied. These look like regular parameters, so they must be
425 separated accordingly. For example,
429 #@application/octet-stream; \\
431 conversions=compress \\
432 [this is the nmh distribution] \\
433 {attachment; filename="nmh.tar.gz"} \\
434 name="nmh.tar.gz"; \\
435 directory="/pub/nmh"; \\
436 site="ftp.math.gatech.edu"; \\
437 access-type=anon-ftp; \\
442 You must give a description string to separate the content parameters
443 from the external-parameters (although this string may be empty).
444 This description string is specified by enclosing it within
445 \*(lq[]\*(rq. A disposition string, to appear in a
446 \*(lqContent-Disposition\*(rq header, may appear in the optional
449 These parameters are of the form:
453 .ta \w'access-type= 'u
454 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
456 permission= read-only or read-write
458 directory= directoryname (optional)
459 mode= usually \fIascii\fR or \fIimage\fR (optional)
460 size= number of octets
462 subject= subject to send
463 body= command to send for retrieval
468 A mimimum \*(lqexternal\-type\*(rq directive for the
475 #@application/octet-stream [] access-type=url; \\
476 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
480 Any long URLs will be wrapped according to RFC 2231 rules.
482 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
483 group of messages to include. You may optionally specify the name of
484 the folder and which messages are to be forwarded. If a folder is not
485 given, it defaults to the current folder. Similarly, if a message is not
486 given, it defaults to the current message. Hence, the message directive
489 command, except that the former uses
490 the MIME rules for encapsulation rather than those specified in RFC 934.
495 #forw +inbox 42 43 99
499 If you include a single message, it will be included directly as a content
500 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
503 will add a content of type \*(lqmultipart/digest\*(rq
504 and include each message as a subpart of this content.
506 If you are using this directive to include more than one message, you
509 switch. This switch will indicate that
511 should attempt to utilize the MIME encapsulation rules
512 in such a way that the \*(lqmultipart/digest\*(rq that is created
513 is (mostly) compatible with the encapsulation specified in RFC 934.
514 If given, then RFC 934 compliant user-agents should be able to burst the
515 message on reception\0--\0providing that the messages being encapsulated
516 do not contain encapsulated messages themselves. The drawback of this
517 approach is that the encapsulations are generated by placing an extra
518 newline at the end of the body of each message.
520 The \*(lqbegin\*(rq directive is used to create a multipart content.
521 When using the \*(lqbegin\*(rq directive, you must specify at least one
522 content between the begin and end pairs.
527 This will be a multipart with only one part.
532 If you use multiple directives in a composition draft,
535 automatically encapsulate them inside a multipart content. Therefore the
536 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
537 multiparts, or create a multipart message containing only one part.
539 For all of these directives, the user may include a brief description
540 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
541 character. This description will be copied into the
542 \*(lqContent-Description\*(rq header when the directive is processed.
546 #forw [important mail from Bob] +bob 1 2 3 4 5
550 Similarly, a disposition string may optionally be provided between
551 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
552 \*(lqContent-Disposition\*(rq header when the directive is processed.
553 If a disposition string is provided that does not contain a filename
554 parameter, and a filename is provided in the directive, it will be
555 added to the \*(lqContent-Disposition\*(rq header. For example, the
560 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
564 creates these message part headers:
568 Content-Type: text/plain; charset="iso-8859-1"
569 Content-Disposition: attachment; filename="summary.txt"
575 will generate a unique \*(lqContent-ID:\*(rq for each directive,
576 corresponding to each message part; however, the user may override
577 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
580 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
581 even in the top level of the message.
585 will choose an appropriate Content\-Transfer\-Encoding based on the content
586 and the MIME Content\-Type. However, you can override that in an
588 directive by specifying \*(lq*\*(rq and the encoding. Acceptable encoding
589 values are \*(lq8bit\*(rq, \*(lqqp\*(rq (for quoted\-printable), and
590 \*(lqb64\*(rq (for base64 encoding). It should be noted that undesired
591 results may occur if 8bit or quoted\-printable is selected for binary
592 content, due to the translation between Unix line endings and the line
593 endings use by the mail transport system.
595 In addition to the various directives, plaintext can be present.
596 Plaintext is gathered, until a directive is found or the draft is
597 exhausted, and this is made to form a text content. If the plaintext
598 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
602 ##when sent, this line will start with only one #
605 If you want to end the plaintext prior to a directive, e.g., to have two
606 plaintext contents adjacent, simply insert a line containing a single
607 \*(lq#\*(rq character, e.g.,
611 this is the first content
613 and this is the second
617 Finally, if the plaintext starts with a line of the form:
620 Content-Description: text
623 then this will be used to describe the plaintext content.
624 You MUST follow this line with a blank line before starting
627 By default, plaintext is captured as a text/plain content. You can
628 override this by starting the plaintext with \*(lq#<\*(rq followed by
629 a content-type specification. For example, e.g.,
634 this content will be tagged as text/enriched
636 and this content will be tagged as text/plain
638 #<application/x-patch [this is a patch]
639 and this content will be tagged as application/x-patch
643 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
644 content-description must be on the same line which identifies the content
645 type of the plaintext.
647 When composing a text content, you may indicate the relevant character
648 set by adding the \*(lqcharset\*(rq parameter to the directive.
651 #<text/plain; charset=iso-8859-5
654 If a text content contains any 8\-bit characters (characters with the
655 high bit set) and the character set is not specified as above, then
657 will assume the character set is of the type given by the
660 environment variables. If these environment variables are not
661 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
663 If a text content contains only 7\-bit characters and the character set
664 is not specified as above, then the character set will be labeled as
667 By default text content with the high bit set is encoded with a 8bit
668 Content\-Transfer\-Encoding. If the text has lines longer than the value
671 (which defaults to 78) then the text is encoded using the quoted\-printable
676 switch will indicate which algorithm to use when encoding any message headers
677 that contain 8\-bit characters. The valid arguments are
679 for based\-64 encoding and
681 for quoted\-printable encoding. The
682 .B \-autoheaderencoding
685 to automatically pick the algorithm that results in a shorter encoded string.
687 Putting this all together,
688 here is an example of a more complicated message draft. The
689 following draft will expand into a multipart/mixed message
690 containing five parts:
694 To: nobody@nowhere.org
696 Subject: Look and listen to me!
698 The first part will be text/plain
700 The second part will be text/enriched
702 This third part will be text/plain
703 #audio/basic [silly giggle] \\
704 |raw2audio -F < /usr/lib/sounds/giggle.au
705 #image/gif [photo of foobar] \\
706 /home/foobar/lib/picture.gif
709 .SS "Integrity Check"
714 switch, then it will also associate an integrity check with each
715 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
716 the content, along with the md5 sum of the unencoded contents, per RFC
717 1864. This may be used by the receiver of the message to verify that
718 the contents of the message were not changed in transport.
719 .SS "Transfer Encodings"
722 constructs the new MIME message by parsing directives,
723 including files, etc., it scans the contents of the message to determine
724 which transfer encoding to use. It will check for 8bit data, long lines,
725 spaces at the end of lines, and clashes with multipart boundaries. It will
726 then choose a transfer encoding appropriate for each content type.
728 If an integrity check is being associated with each content by using
733 will encode each content with
734 a transfer encoding, even it the content contains only 7\-bit data. This
735 is to increase the likelihood that the content is not changed while in
737 .SS "Invoking mhbuild"
743 command will expect the body of the draft to be formatted as an
745 composition file. Once you have composed this input file
746 using a command such as
753 at the \*(lqWhat now\*(rq prompt with
759 prior to sending the draft. This will cause
763 to translate the composition file into MIME format.
765 Normally it is an error to invoke
767 on file that already in MIME format. The
771 to exit without error if the input file already has valid MIME headers.
778 Finally, you should consider adding this line to your profile:
784 This way, if you decide to
794 will work as you expect.
798 switch is intended to be used by
800 It will cause mhbuild to not generate any MIME headers in the composition
801 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
802 will still encode message headers according to RFC 2047.
803 .SS "User Environment"
804 Because the environment in which
806 operates may vary for a
809 will look for the environment variable
811 If present, this specifies the name of an additional user profile which
812 should be read. Hence, when a user logs in on a particular machine,
813 this environment variable should be set to refer to a file containing
814 definitions useful for that machine.
818 will attempt to consult
821 %nmhetcdir%/mhn.defaults
826 See "Profile Lookup" in
828 for the profile search order, and for how duplicate entries are treated.
829 .SS "Syntax of Composition Files"
830 The following is the formal syntax of a
832 \*(lqcomposition file\*(rq.
836 body ::= 1*(content | EOL)
838 content ::= directive | plaintext
840 directive ::= "#" type "/" subtype
841 0*(";" attribute "=" value)
844 [ "[" description "]" ]
845 [ "{" disposition "}" ]
846 [ "*8bit" | "*qp" | "*b64" ]
850 | "#@" type "/" subtype
851 0*(";" attribute "=" value)
854 [ "[" description "]" ]
855 [ "{" disposition "}" ]
856 [ "*8bit" | "*qp" | "*b64" ]
862 [ "[" description "]" ]
863 [ "{" disposition "}" ]
864 [ "+"folder ] [ 0*msg ]
869 [ "[" description "]" ]
870 [ "{" disposition "}" ]
878 plaintext ::= [ "Content-Description:"
879 description EOL EOL ]
883 | "#<" type "/" subtype
884 0*(";" attribute "=" value)
886 [ "[" description "]" ]
887 [ "{" disposition "}" ]
888 [ "*8bit" | "*qp" | "*b64" ]
893 line ::= "##" text EOL
894 -- interpreted as "#"text EOL
900 looks for additional user profile files and mhn.defaults in multiple
901 locations: absolute pathnames are accessed directly, tilde expansion
902 is done on usernames, and files are searched for in the user's
904 directory as specified in their profile. If not found there, the directory
905 .RI \*(lq %nmhetcdir% \*(rq
910 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
911 ^$HOME/\&.mh\(ruprofile~^The user profile
912 ^$MHBUILD~^Additional profile entries
913 ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
915 .SH "PROFILE COMPONENTS"
919 .ta \w'ExtraBigProfileName 'u
920 ^Path:~^To determine the user's nmh directory
921 ^Current\-Folder:~^To find the default current folder
922 ^mhbuild-compose-<type>*~^Template for composing contents
932 .I "Proposed Standard for Message Encapsulation"
935 .I "The Content-MD5 Header Field"
938 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
941 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
944 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
947 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
950 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
953 .I "Definition of the URL MIME External-Body Access-Type"
956 .I "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"
962 .RB ` \-norfc934mode '
966 .RB ` \-nodisposition '
967 .RB ` \-autoheaderencoding '
968 .RB ` "\-maxunencoded\ 78"'