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 %docdir%/contrib/replaliases. That script also sets the
271 environment variable if it was not set.
274 .SS "Translating the Composition File"
276 is essentially a filter to aid in the composition of MIME
281 \*(lqcomposition file\*(rq
282 into a valid MIME message. A
284 \*(lqcomposition file\*(rq
285 is just a file containing plain text that is interspersed
288 directives. When this file is processed
291 the various directives will be expanded to the
292 appropriate content, and will be encoded according to the MIME standards.
293 The resulting MIME message can then be sent by electronic mail.
295 The formal syntax for a
297 composition file is defined at the
298 end of this document, but the ideas behind this format are not complex.
299 Basically, the body contains one or more contents. A content consists of
300 either a directive, indicated with a \*(lq#\*(rq as the first character
301 of a line; or, plaintext (one or more lines of text). The continuation
302 character, \*(lq\\\*(lq, may be used to enter a single directive on more
308 /home/foobar/junk/picture.png
312 There are five kinds of directives: \*(lqtype\*(rq directives, which
313 name the type and subtype of the content; \*(lqexternal-type\*(rq
314 directives, which also name the type and subtype of the content; the
315 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
316 more messages; the \*(lqbegin\*(rq directive (#begin), which is
317 used to create a multipart content; and the \*(lqon/off/pop\*(rq
318 directives (#on, #off, #pop) which control whether any other
319 directives are honored at all.
323 switch allows control over whether mhbuild will honor any of the
324 \*(lq#\*(rq-directives. This can also be affected with the #on or
325 #off directives, and #pop, which restores the state of processing to
326 that preceding the most recent #on or #off. (The #on, #off, and #pop
327 directives are always honored, of course.) This allows inclusion of
328 plain text which looks like mhbuild directives, without causing
335 printf("Hello, World!");
340 Currently the stack depth for the #on/off/pop directives is 32.
342 The \*(lqtype\*(rq directive is used to directly specify the type and
343 subtype of a content. You may only specify discrete types in this manner
344 (can't specify the types multipart or message with this directive).
345 You may optionally specify the name of a file containing the contents
346 in \*(lqnative\*(rq (decoded) format. If this filename starts with the
347 \*(lq|\*(rq character, then it represents a command to execute whose
348 output is captured accordingly.
353 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
357 If a filename is not given,
359 will look for information in the
360 user's profile to determine how the different contents should be composed.
361 This is accomplished by consulting a composition string, and executing
364 with the standard output set to the content.
369 will echo any commands that are used to create contents in this way.
371 The composition string may contain the following escapes:
376 %a Insert parameters from directive
377 %f Insert filename containing content
378 %F %f, and stdout is not re-directed
379 %s Insert content subtype
380 %% Insert character %
386 will look for an entry of the form:
389 mhbuild-compose-<type>/<subtype>
392 to determine the command to use to compose the content. If this isn't
395 will look for an entry of the form:
398 mhbuild-compose-<type>
401 to determine the composition command. If this isn't found,
405 An example entry might be:
408 mhbuild-compose-audio/basic: record | raw2audio -F
411 Because commands like these will vary, depending on the display
412 environment used for login, composition strings for different
413 contents should probably be put in the file specified by the
415 environment variable, instead of directly in your
418 The \*(lqexternal-type\*(rq directives are used to provide a MIME
419 reference to a content, rather than enclosing the contents itself
420 (for instance, by specifying an ftp site). Hence, instead of
421 providing a filename as with the type directives, external-parameters
422 are supplied. These look like regular parameters, so they must be
423 separated accordingly. For example,
427 #@application/octet-stream; \\
429 conversions=compress \\
430 [this is the nmh distribution] \\
431 {attachment; filename="nmh.tar.gz"} \\
432 name="nmh.tar.gz"; \\
433 directory="/pub/nmh"; \\
434 site="ftp.math.gatech.edu"; \\
435 access-type=anon-ftp; \\
440 You must give a description string to separate the content parameters
441 from the external-parameters (although this string may be empty).
442 This description string is specified by enclosing it within
443 \*(lq[]\*(rq. A disposition string, to appear in a
444 \*(lqContent-Disposition\*(rq header, may appear in the optional
447 These parameters are of the form:
451 .ta \w'access-type= 'u
452 access-type= usually \fIanon-ftp\fR, \fImail-server\fR, or \fIurl\fR
454 permission= read-only or read-write
456 directory= directoryname (optional)
457 mode= usually \fIascii\fR or \fIimage\fR (optional)
458 size= number of octets
460 subject= subject to send
461 body= command to send for retrieval
466 A mimimum \*(lqexternal\-type\*(rq directive for the
473 #@application/octet-stream [] access-type=url; \\
474 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
478 Any long URLs will be wrapped according to RFC 2231 rules.
480 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
481 group of messages to include. You may optionally specify the name of
482 the folder and which messages are to be forwarded. If a folder is not
483 given, it defaults to the current folder. Similarly, if a message is not
484 given, it defaults to the current message. Hence, the message directive
487 command, except that the former uses
488 the MIME rules for encapsulation rather than those specified in RFC 934.
493 #forw +inbox 42 43 99
497 If you include a single message, it will be included directly as a content
498 of type \*(lqmessage/rfc822\*(rq. If you include more than one message,
501 will add a content of type \*(lqmultipart/digest\*(rq
502 and include each message as a subpart of this content.
504 If you are using this directive to include more than one message, you
507 switch. This switch will indicate that
509 should attempt to utilize the MIME encapsulation rules
510 in such a way that the \*(lqmultipart/digest\*(rq that is created
511 is (mostly) compatible with the encapsulation specified in RFC 934.
512 If given, then RFC 934 compliant user-agents should be able to burst the
513 message on reception\0--\0providing that the messages being encapsulated
514 do not contain encapsulated messages themselves. The drawback of this
515 approach is that the encapsulations are generated by placing an extra
516 newline at the end of the body of each message.
518 The \*(lqbegin\*(rq directive is used to create a multipart content.
519 When using the \*(lqbegin\*(rq directive, you must specify at least one
520 content between the begin and end pairs.
525 This will be a multipart with only one part.
530 If you use multiple directives in a composition draft,
533 automatically encapsulate them inside a multipart content. Therefore the
534 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
535 multiparts, or create a multipart message containing only one part.
537 For all of these directives, the user may include a brief description
538 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
539 character. This description will be copied into the
540 \*(lqContent-Description\*(rq header when the directive is processed.
544 #forw [important mail from Bob] +bob 1 2 3 4 5
548 Similarly, a disposition string may optionally be provided between
549 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
550 \*(lqContent-Disposition\*(rq header when the directive is processed.
551 If a disposition string is provided that does not contain a filename
552 parameter, and a filename is provided in the directive, it will be
553 added to the \*(lqContent-Disposition\*(rq header. For example, the
558 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
562 creates these message part headers:
566 Content-Type: text/plain; charset="iso-8859-1"
567 Content-Disposition: attachment; filename="summary.txt"
573 will generate a unique \*(lqContent-ID:\*(rq for each directive,
574 corresponding to each message part; however, the user may override
575 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
578 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
579 even in the top level of the message.
583 will choose an appropriate Content\-Transfer\-Encoding based on the content
584 and the MIME Content\-Type. However, you can override that in an
586 directive by specifying \*(lq*\*(rq and the encoding. Acceptable encoding
587 values are \*(lq8bit\*(rq, \*(lqqp\*(rq (for quoted\-printable), and
588 \*(lqb64\*(rq (for base64 encoding). It should be noted that undesired
589 results may occur if 8bit or quoted\-printable is selected for binary
590 content, due to the translation between Unix line endings and the line
591 endings use by the mail transport system.
593 In addition to the various directives, plaintext can be present.
594 Plaintext is gathered, until a directive is found or the draft is
595 exhausted, and this is made to form a text content. If the plaintext
596 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
600 ##when sent, this line will start with only one #
603 If you want to end the plaintext prior to a directive, e.g., to have two
604 plaintext contents adjacent, simply insert a line containing a single
605 \*(lq#\*(rq character, e.g.,
609 this is the first content
611 and this is the second
615 Finally, if the plaintext starts with a line of the form:
618 Content-Description: text
621 then this will be used to describe the plaintext content.
622 You MUST follow this line with a blank line before starting
625 By default, plaintext is captured as a text/plain content. You can
626 override this by starting the plaintext with \*(lq#<\*(rq followed by
627 a content-type specification. For example, e.g.,
632 this content will be tagged as text/enriched
634 and this content will be tagged as text/plain
636 #<application/x-patch [this is a patch]
637 and this content will be tagged as application/x-patch
641 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
642 content-description must be on the same line which identifies the content
643 type of the plaintext.
645 When composing a text content, you may indicate the relevant character
646 set by adding the \*(lqcharset\*(rq parameter to the directive.
649 #<text/plain; charset=iso-8859-5
652 If a text content contains any 8\-bit characters (characters with the
653 high bit set) and the character set is not specified as above, then
655 will assume the character set is of the type given by the
658 environment variables. If these environment variables are not
659 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
661 If a text content contains only 7\-bit characters and the character set
662 is not specified as above, then the character set will be labeled as
665 By default text content with the high bit set is encoded with a 8bit
666 Content\-Transfer\-Encoding. If the text has lines longer than the value
669 (which defaults to 78) then the text is encoded using the quoted\-printable
674 switch will indicate which algorithm to use when encoding any message headers
675 that contain 8\-bit characters. The valid arguments are
677 for based\-64 encoding and
679 for quoted\-printable encoding. The
680 .B \-autoheaderencoding
683 to automatically pick the algorithm that results in a shorter encoded string.
685 Putting this all together,
686 here is an example of a more complicated message draft. The
687 following draft will expand into a multipart/mixed message
688 containing five parts:
692 To: nobody@nowhere.org
694 Subject: Look and listen to me!
696 The first part will be text/plain
698 The second part will be text/enriched
700 This third part will be text/plain
701 #audio/basic [silly giggle] \\
702 |raw2audio -F < /usr/lib/sounds/giggle.au
703 #image/gif [photo of foobar] \\
704 /home/foobar/lib/picture.gif
707 .SS "Integrity Check"
712 switch, then it will also associate an integrity check with each
713 \*(lqleaf\*(rq content. This will add a Content-MD5 header field to
714 the content, along with the md5 sum of the unencoded contents, per RFC
715 1864. This may be used by the receiver of the message to verify that
716 the contents of the message were not changed in transport.
717 .SS "Transfer Encodings"
720 constructs the new MIME message by parsing directives,
721 including files, etc., it scans the contents of the message to determine
722 which transfer encoding to use. It will check for 8bit data, long lines,
723 spaces at the end of lines, and clashes with multipart boundaries. It will
724 then choose a transfer encoding appropriate for each content type.
726 If an integrity check is being associated with each content by using
731 will encode each content with
732 a transfer encoding, even it the content contains only 7\-bit data. This
733 is to increase the likelihood that the content is not changed while in
735 .SS "Invoking mhbuild"
741 command will expect the body of the draft to be formatted as an
743 composition file. Once you have composed this input file
744 using a command such as
751 at the \*(lqWhat now\*(rq prompt with
757 prior to sending the draft. This will cause
761 to translate the composition file into MIME format.
763 Normally it is an error to invoke
765 on file that already in MIME format. The
769 to exit without error if the input file already has valid MIME headers.
776 Finally, you should consider adding this line to your profile:
782 This way, if you decide to
792 will work as you expect.
796 switch is intended to be used by
798 It will cause mhbuild to not generate any MIME headers in the composition
799 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
800 will still encode message headers according to RFC 2047.
801 .SS "User Environment"
802 Because the environment in which
804 operates may vary for a
807 will look for the environment variable
809 If present, this specifies the name of an additional user profile which
810 should be read. Hence, when a user logs in on a particular machine,
811 this environment variable should be set to refer to a file containing
812 definitions useful for that machine.
816 will attempt to consult
819 %nmhetcdir%/mhn.defaults
824 See "Profile Lookup" in
826 for the profile search order, and for how duplicate entries are treated.
827 .SS "Syntax of Composition Files"
828 The following is the formal syntax of a
830 \*(lqcomposition file\*(rq.
834 body ::= 1*(content | EOL)
836 content ::= directive | plaintext
838 directive ::= "#" type "/" subtype
839 0*(";" attribute "=" value)
842 [ "[" description "]" ]
843 [ "{" disposition "}" ]
844 [ "*8bit" | "*qp" | "*b64" ]
848 | "#@" type "/" subtype
849 0*(";" attribute "=" value)
852 [ "[" description "]" ]
853 [ "{" disposition "}" ]
854 [ "*8bit" | "*qp" | "*b64" ]
860 [ "[" description "]" ]
861 [ "{" disposition "}" ]
862 [ "+"folder ] [ 0*msg ]
867 [ "[" description "]" ]
868 [ "{" disposition "}" ]
876 plaintext ::= [ "Content-Description:"
877 description EOL EOL ]
881 | "#<" type "/" subtype
882 0*(";" attribute "=" value)
884 [ "[" description "]" ]
885 [ "{" disposition "}" ]
886 [ "*8bit" | "*qp" | "*b64" ]
891 line ::= "##" text EOL
892 -- interpreted as "#"text EOL
898 looks for additional user profile files and mhn.defaults in multiple
899 locations: absolute pathnames are accessed directly, tilde expansion
900 is done on usernames, and files are searched for in the user's
902 directory as specified in their profile. If not found there, the directory
903 .RI \*(lq %nmhetcdir% \*(rq
908 .ta \w'%nmhetcdir%/ExtraBigFileName 'u
909 ^$HOME/\&.mh\(ruprofile~^The user profile
910 ^$MHBUILD~^Additional profile entries
911 ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries
913 .SH "PROFILE COMPONENTS"
917 .ta \w'ExtraBigProfileName 'u
918 ^Path:~^To determine the user's nmh directory
919 ^Current\-Folder:~^To find the default current folder
920 ^mhbuild-compose-<type>*~^Template for composing contents
930 .I "Proposed Standard for Message Encapsulation"
933 .I "The Content-MD5 Header Field"
936 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
939 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
942 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
945 .I "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures"
948 .I "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples"
951 .I "Definition of the URL MIME External-Body Access-Type"
954 .I "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"
960 .RB ` \-norfc934mode '
964 .RB ` \-nodisposition '
965 .RB ` \-autoheaderencoding '
966 .RB ` "\-maxunencoded\ 78"'