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
40 This includes the encoding of message headers as specified
41 by RFC 2047, and the encoding of MIME parameters as specified in RFC 2231.
43 If you specify the name of the composition file as \*(lq-\*(rq,
46 will accept the composition draft on the standard
48 If the translation of this input is successful,
50 will output the new MIME message to the standard output.
52 must be the last argument on the command line.
54 Otherwise if the file argument to
56 is the name of a valid
57 composition file, and the translation is successful,
59 will replace the original file with the new MIME message.
61 the original file to start with the \*(lq,\*(rq character and end with the
62 string \*(lq.orig\*(rq, e.g., if you are editing the file \*(lqdraft\*(rq,
63 it will be renamed to \*(lq,draft.orig\*(rq.
64 This allows you to easily
68 .SS "Listing the Contents"
73 to list the table of contents associated with the MIME message that is created.
78 that a one-line banner should be displayed above the listing.
83 to evaluate the \*(lqnative\*(rq
84 (decoded) format of each content prior to listing.
86 accurate count at the expense of a small delay.
90 is present, then the listing will show any \*(lqextra\*(rq information
91 that is present in the message, such as comments in the
92 \*(lqContent-Type\*(rq header.
96 switch is present, then the listing will show any relevant information from
97 the \*(lqContent-Disposition\*(rq header.
98 .SS "Simplified Attachment Interface"
99 For users who wish to simply attach files to text content,
101 will scan the composition file for \*(lqAttach\*(rq headers.
103 \*(lqAttach\*(rq header contains a filename that will be appended to the
104 message using normal MIME encapsulation rules.
105 One filename is allowed
106 per \*(lqAttach\*(rq header, but multiple \*(lqAttach\*(rq headers are
107 allowed ber composition file.
109 These files will be appended after any other MIME content, including any
112 directives (see below).
117 By default, the Content-Disposition will be \*(lqattachment\*(rq.
119 looks for user profile and
124 .BI mhbuild-disposition- type / subtype
128 .BI mhbuild-disposition- type
131 to supply the disposition value.
132 The only supported values are
136 .SS "Convert Interface"
137 The convert interface is a powerful mechanism that supports
138 replying to MIME messages.
139 These placeholders are used in the following
148 external program, and any fixed arguments, to convert content, such as
149 from a request to a reply
152 arguments to pass from
158 full path of message being replied to
163 The convert support is based on pseudoheaders of the form
167 .BI Nmh-mhbuild-file- TYPE : \0FILE
168 .BI Nmh-mhbuild-args- TYPE : \0ARGSTRING
173 For each such pseudoheader, mhbuild looks in the
176 for this corresponding
179 converter that supports it:
182 .BI mhbuild-convert- TYPE : \0CONVERTER
185 It's a fatal error if no such entry is found for
191 .B mhbuild-convert-text/html:
194 excludes parts of that
201 .B mhbuild-convert-text/html
203 .BR mhbuild-convert-text/plain
205 Profile entries can be used to override corresponding
215 .I CONVERTER ARGSTRING
216 on the content of the part.
220 that has no corresponding TYPE entry in the profile or
223 excluded from the draft; the user can include them using mhbuild
228 .B Nmh-mhbuild-text/html:
230 .B Nmh-mhbuild-text/plain:
231 pseudoheaders in every draft.
232 The user can prevent insertion of
233 content parts of either of those types by putting corresponding empty
234 entries in their profile.
236 Only the highest precedence alternative with a supported
238 of a multipart/alternative part is used.
240 mhn.defaults.sh selects the text/html-to-text/plain converter at
248 in the pipeline only if they are found.
250 Some content types require the addition of parameters to the
251 Content-Type header, such as
252 \*(lqmethod=REPLY\*(rq
255 looks for a Content-Type header, followed
256 by a blank line, at the beginning of the converter output.
258 found, it is used for the corresponding part in the reply draft.
260 The convert interface doesn't support different
262 or different converters for different parts of the same
264 That would require associating parts by part number with the
267 Instead, that can be done (currently, without using
268 the convert support), with
270 directives as described below, e.g.,
273 #text/html; charset=utf-8 *8bit | mhstore -noverbose -part 42.7 -outfile - | w3m -dump -cols 64 -T text/html -O utf-8
280 directives is to insert the directives before
282 is run, which is typically done by entering
284 at the \*(lqWhat now?\*(rq prompt, or with an
288 These (optional) setup steps can make the convert support
294 program is installed on your system, it will be set by default
297 to filter the converter output.
301 environment variable, as described in its man page.
304 Add this line to your profile:
306 mhbuild-next: $EDITOR
308 assuming that your EDTIOR environment variable is set; if not, replace
309 EDITOR with the name of your editor.
310 Without that profile entry, a
311 response of \*(lqe[dit]\*(rq at the What now? prompt will require
312 specification of your editor if an
320 source the Bourne-shell compatible functions in
321 .IR %docdir%/contrib/replaliases .
323 That script also sets the
325 environment variable if it was not set.
327 .SS "Translating the Composition File"
329 is essentially a filter to aid in the composition of MIME
334 \*(lqcomposition file\*(rq
335 into a valid MIME message.
338 \*(lqcomposition file\*(rq
339 is just a file containing plain text that is interspersed
343 When this file is processed
346 the various directives will be expanded to the
347 appropriate content, and will be encoded according to the MIME standards.
348 The resulting MIME message can then be sent by electronic mail.
350 The formal syntax for a
352 composition file is defined at the
353 end of this document, but the ideas behind this format are not complex.
354 Basically, the body contains one or more contents.
355 A content consists of
356 either a directive, indicated with a \*(lq#\*(rq as the first character
357 of a line; or, plaintext (one or more lines of text).
359 character, \*(lq\\\*(lq, may be used to enter a single directive on more
365 /home/foobar/junk/picture.png
369 There are five kinds of directives: \*(lqtype\*(rq directives, which
370 name the type and subtype of the content; \*(lqexternal-type\*(rq
371 directives, which also name the type and subtype of the content; the
372 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
373 more messages; the \*(lqbegin\*(rq directive (#begin), which is
374 used to create a multipart content; and the \*(lqon/off/pop\*(rq
375 directives (#on, #off, #pop) which control whether any other
376 directives are honored at all.
380 switch allows control over whether mhbuild will honor any of the
381 \*(lq#\*(rq-directives.
382 This can also be affected with the #on or
383 #off directives, and #pop, which restores the state of processing to
384 that preceding the most recent #on or #off.
385 (The #on, #off, and #pop
386 directives are always honored, of course.) This allows inclusion of
387 plain text which looks like mhbuild directives, without causing
394 printf("Hello, World!");
399 Currently the stack depth for the #on/off/pop directives is 32.
401 The \*(lqtype\*(rq directive is used to directly specify the type and
402 subtype of a content.
403 You may only specify discrete types in this manner
404 (can't specify the types multipart or message with this directive).
405 You may optionally specify the name of a file containing the contents
406 in \*(lqnative\*(rq (decoded) format.
407 If this filename starts with the
408 \*(lq|\*(rq character, then it represents a command to execute whose
409 output is captured accordingly.
414 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
418 If a filename is not given,
420 will look for information in the
421 user's profile to determine how the different contents should be composed.
422 This is accomplished by consulting a composition string, and executing
425 with the standard output set to the content.
430 will echo any commands that are used to create contents in this way.
432 The composition string may contain the following escapes:
437 Insert parameters from directive
439 Insert filename containing content
441 %f, and stdout is not re-directed
443 Insert content subtype
451 will look for an entry of the form:
454 .BI mhbuild-compose- type / subtype
457 to determine the command to use to compose the content.
461 will look for an entry of the form:
464 .BI mhbuild-compose- type
467 to determine the composition command.
472 An example entry might be:
475 mhbuild-compose-audio/basic: record | raw2audio -F
478 Because commands like these will vary, depending on the display
479 environment used for login, composition strings for different
480 contents should probably be put in the file specified by the
482 environment variable, instead of directly in your
485 The \*(lqexternal-type\*(rq directives are used to provide a MIME
486 reference to a content, rather than enclosing the contents itself
487 (for instance, by specifying an ftp site).
489 providing a filename as with the type directives, external-parameters
491 These look like regular parameters, so they must be
492 separated accordingly.
497 #@application/octet-stream; \\
499 conversions=compress \\
500 [this is the nmh distribution] \\
501 {attachment; filename="nmh.tar.gz"} \\
502 name="nmh.tar.gz"; \\
503 directory="/pub/nmh"; \\
504 site="ftp.math.gatech.edu"; \\
505 access-type=anon-ftp; \\
510 You must give a description string to separate the content parameters
511 from the external-parameters (although this string may be empty).
512 This description string is specified by enclosing it within
514 A disposition string, to appear in a
515 \*(lqContent-Disposition\*(rq header, may appear in the optional
518 These parameters are of the form:
522 .ta \w'access-type= 'u
523 access-type= usually \*(lqanon-ftp\*(rq, \*(lqmail-server\*(rq, or \*(lqurl\*(rq
525 permission= read-only or read-write
527 directory= directoryname (optional)
528 mode= usually \*(lqascii\*(rq or \*(lqimage\*(rq (optional)
529 size= number of octets
531 subject= subject to send
532 body= command to send for retrieval
537 A mimimum \*(lqexternal\-type\*(rq directive for the
544 #@application/octet-stream [] access-type=url; \\
545 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
549 Any long URLs will be wrapped according to RFC 2231 rules.
551 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
552 group of messages to include.
553 You may optionally specify the name of
554 the folder and which messages are to be forwarded.
556 given, it defaults to the current folder.
557 Similarly, if a message is not
558 given, it defaults to the current message.
559 Hence, the message directive
562 command, except that the former uses
563 the MIME rules for encapsulation rather than those specified in RFC 934.
568 #forw +inbox 42 43 99
572 If you include a single message, it will be included directly as a content
573 of type \*(lqmessage/rfc822\*(rq.
574 If you include more than one message,
577 will add a content of type \*(lqmultipart/digest\*(rq
578 and include each message as a subpart of this content.
580 If you are using this directive to include more than one message, you
584 This switch will indicate that
586 should attempt to utilize the MIME encapsulation rules
587 in such a way that the \*(lqmultipart/digest\*(rq that is created
588 is (mostly) compatible with the encapsulation specified in RFC 934.
589 If given, then RFC 934 compliant user-agents should be able to burst the
590 message on reception\0--\0providing that the messages being encapsulated
591 do not contain encapsulated messages themselves.
593 approach is that the encapsulations are generated by placing an extra
594 newline at the end of the body of each message.
596 The \*(lqbegin\*(rq directive is used to create a multipart content.
597 When using the \*(lqbegin\*(rq directive, you must specify at least one
598 content between the begin and end pairs.
603 This will be a multipart with only one part.
608 If you use multiple directives in a composition draft,
611 automatically encapsulate them inside a multipart content.
613 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
614 multiparts, or create a multipart message containing only one part.
616 For all of these directives, the user may include a brief description
617 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
619 This description will be copied into the
620 \*(lqContent-Description\*(rq header when the directive is processed.
624 #forw [important mail from Bob] +bob 1 2 3 4 5
628 Similarly, a disposition string may optionally be provided between
629 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
630 \*(lqContent-Disposition\*(rq header when the directive is processed.
631 If a disposition string is provided that does not contain a filename
632 parameter, and a filename is provided in the directive, it will be
633 added to the \*(lqContent-Disposition\*(rq header.
639 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
643 creates these message part headers:
647 Content-Type: text/plain; charset="iso-8859-1"
648 Content-Disposition: attachment; filename="summary.txt"
654 will generate a unique \*(lqContent-ID:\*(rq for each directive,
655 corresponding to each message part; however, the user may override
656 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
660 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
661 even in the top level of the message.
665 will choose an appropriate Content\-Transfer\-Encoding based on the content
666 and the MIME Content\-Type.
667 However, you can override that in an
669 directive by specifying \*(lq*\*(rq and the encoding.
671 values are \*(lq8bit\*(rq, \*(lqqp\*(rq (for quoted\-printable), and
672 \*(lqb64\*(rq (for base64 encoding).
673 It should be noted that undesired
674 results may occur if 8bit or quoted\-printable is selected for binary
675 content, due to the translation between Unix line endings and the line
676 endings use by the mail transport system.
678 In addition to the various directives, plaintext can be present.
679 Plaintext is gathered, until a directive is found or the draft is
680 exhausted, and this is made to form a text content.
682 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
686 ##when sent, this line will start with only one #
689 If you want to end the plaintext prior to a directive, e.g., to have two
690 plaintext contents adjacent, simply insert a line containing a single
691 \*(lq#\*(rq character, e.g.,
695 this is the first content
697 and this is the second
701 Finally, if the plaintext starts with a line of the form:
704 Content-Description: text
707 then this will be used to describe the plaintext content.
708 You MUST follow this line with a blank line before starting
711 By default, plaintext is captured as a text/plain content.
713 override this by starting the plaintext with \*(lq#<\*(rq followed by
714 a content-type specification.
720 this content will be tagged as text/enriched
722 and this content will be tagged as text/plain
724 #<application/x-patch [this is a patch]
725 and this content will be tagged as application/x-patch
729 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
730 content-description must be on the same line which identifies the content
731 type of the plaintext.
733 When composing a text content, you may indicate the relevant character
734 set by adding the \*(lqcharset\*(rq parameter to the directive.
737 #<text/plain; charset=iso-8859-5
740 If a text content contains any 8\-bit characters (characters with the
741 high bit set) and the character set is not specified as above, then
743 will assume the character set is of the type given by the
746 environment variables.
747 If these environment variables are not
748 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
750 If a text content contains only 7\-bit characters and the character set
751 is not specified as above, then the character set will be labeled as
754 By default text content with the high bit set is encoded with a 8bit
755 Content\-Transfer\-Encoding.
756 If the text has lines longer than the value
759 (which defaults to 78) then the text is encoded using the quoted\-printable
764 switch will indicate which algorithm to use when encoding any message headers
765 that contain 8\-bit characters.
766 The valid arguments are
768 for based\-64 encoding and
770 for quoted\-printable encoding.
772 .B \-autoheaderencoding
775 to automatically pick the algorithm that results in a shorter encoded string.
777 Putting this all together,
778 here is an example of a more complicated message draft.
780 following draft will expand into a multipart/mixed message
781 containing five parts:
785 To: nobody@nowhere.org
787 Subject: Look and listen to me!
789 The first part will be text/plain
791 The second part will be text/enriched
793 This third part will be text/plain
794 #audio/basic [silly giggle] \\
795 |raw2audio -F < /usr/lib/sounds/giggle.au
796 #image/gif [photo of foobar] \\
797 /home/foobar/lib/picture.gif
800 .SS "Integrity Check"
805 switch, then it will also associate an integrity check with each
806 \*(lqleaf\*(rq content.
807 This will add a Content-MD5 header field to
808 the content, along with the md5 sum of the unencoded contents, per RFC
810 This may be used by the receiver of the message to verify that
811 the contents of the message were not changed in transport.
812 .SS "Transfer Encodings"
815 constructs the new MIME message by parsing directives,
816 including files, etc., it scans the contents of the message to determine
817 which transfer encoding to use.
818 It will check for 8bit data, long lines,
819 spaces at the end of lines, and clashes with multipart boundaries.
821 then choose a transfer encoding appropriate for each content type.
823 If an integrity check is being associated with each content by using
828 will encode each content with
829 a transfer encoding, even it the content contains only 7\-bit data.
831 is to increase the likelihood that the content is not changed while in
833 .SS "Invoking mhbuild"
840 command will expect the body of the draft to be formatted as an
843 Once you have composed this input file
844 using a command such as
851 at the \*(lqWhat now\*(rq prompt with
857 prior to sending the draft.
862 to translate the composition file into MIME format.
864 Normally it is an error to invoke
866 on file that already in MIME format.
871 to exit without error if the input file already has valid MIME headers.
878 Finally, you should consider adding this line to your profile:
884 This way, if you decide to
894 will work as you expect.
898 switch is intended to be used by
900 It will cause mhbuild to not generate any MIME headers in the composition
901 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
902 will still encode message headers according to RFC 2047.
903 .SS "User Environment"
904 Because the environment in which
906 operates may vary for a
909 will look for the environment variable
911 If present, this specifies the name of an additional user profile which
913 Hence, when a user logs in on a particular machine,
914 this environment variable should be set to refer to a file containing
915 definitions useful for that machine.
919 will attempt to consult
922 %nmhetcdir%/mhn.defaults
927 See "Profile Lookup" in
929 for the profile search order, and for how duplicate entries are treated.
930 .SS "Syntax of Composition Files"
931 The following is the formal syntax of a
933 \*(lqcomposition file\*(rq.
937 body ::= 1*(content | EOL)
939 content ::= directive | plaintext
941 directive ::= "#" type "/" subtype
942 0*(";" attribute "=" value)
945 [ "[" description "]" ]
946 [ "{" disposition "}" ]
947 [ "*8bit" | "*qp" | "*b64" ]
951 | "#@" type "/" subtype
952 0*(";" attribute "=" value)
955 [ "[" description "]" ]
956 [ "{" disposition "}" ]
957 [ "*8bit" | "*qp" | "*b64" ]
963 [ "[" description "]" ]
964 [ "{" disposition "}" ]
965 [ "+"folder ] [ 0*msg ]
970 [ "[" description "]" ]
971 [ "{" disposition "}" ]
979 plaintext ::= [ "Content-Description:"
980 description EOL EOL ]
984 | "#<" type "/" subtype
985 0*(";" attribute "=" value)
987 [ "[" description "]" ]
988 [ "{" disposition "}" ]
989 [ "*8bit" | "*qp" | "*b64" ]
994 line ::= "##" text EOL
995 -- interpreted as "#"text EOL
1001 looks for additional user profile files and
1004 locations: absolute pathnames are accessed directly, tilde expansion
1005 is done on usernames, and files are searched for in the user's
1007 directory as specified in their profile.
1008 If not found there, the directory
1009 .RI \*(lq %nmhetcdir% \*(rq
1014 $HOME/\&.mh\(ruprofile
1018 Additional profile entries.
1020 %nmhetcdir%/mhn.defaults
1021 System default MIME profile entries.
1023 .SH "PROFILE COMPONENTS"
1027 To determine the user's nmh directory.
1030 To find the default current folder.
1032 .RI mhbuild-compose- type* :
1033 Template for composing contents.
1040 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
1043 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
1046 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
1049 .I "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"
1052 .I "Proposed Standard for Message Encapsulation"
1055 .I "The Content-MD5 Header Field"
1058 .I "Definition of the URL MIME External-Body Access-Type"
1062 \-autoheaderencoding