1 .TH MHBUILD %manext1% "October 15, 2016" "%nmhversion%"
6 mhbuild \- translate MIME composition draft
14 .RB [ \-auto " | " \-noauto ]
15 .RB [ \-list " | " \-nolist ]
16 .RB [ \-realsize " | " \-norealsize ]
17 .RB [ \-headers " | " \-noheaders ]
18 .RB [ \-directives " | " \-nodirectives ]
19 .RB [ \-rfc934mode " | " \-norfc934mode ]
20 .RB [ \-contentid " | " \-nocontentid ]
21 .RB [ \-verbose " | " \-noverbose ]
22 .RB [ \-disposition " | " \-nodisposition ]
23 .RB [ \-check " | " \-nocheck ]
24 .RB [ \-headerencoding
25 .IR encoding\-algorithm
26 .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 per 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
202 .B mhbuild-convert-text/html
204 .BR mhbuild-convert-text/plain
206 Profile entries can be used to override corresponding
208 entries, as usual. Text converters should limit text line lengths
209 to a maximum of 78 characters, and must limit them to a maximum of 998
210 characters, per RFC 5322 Sec.\& 2.1.1.
218 .I CONVERTER ARGSTRING
219 on the content of the part.
222 that has no corresponding TYPE entry in the profile or
225 excluded from the draft; the user can include them using mhbuild
230 .B Nmh-mhbuild-text/html:
232 .B Nmh-mhbuild-text/plain:
233 pseudoheaders in every draft.
234 The user can prevent insertion of
235 content parts of either of those types by putting corresponding empty
236 entries in their profile.
238 Only the highest precedence alternative with a supported
240 of a multipart/alternative part is used.
242 mhn.defaults.sh selects the text/html-to-text/plain converter at
250 in the pipeline only if they are found.
252 Some content types require the addition of parameters to the
253 Content-Type header, such as
254 \*(lqmethod=REPLY\*(rq
257 looks for a Content-Type header, followed
258 by a blank line, at the beginning of the converter output.
260 found, it is used for the corresponding part in the reply draft.
262 The convert interface doesn't support different
264 or different converters for different parts of the same
266 That would require associating parts by part number with the
269 Instead, that can be done (currently, without using
270 the convert support), with
272 directives as described below, e.g.,
275 #text/html; charset=utf-8 *8bit | mhstore -noverbose -part 42.7 -outfile - | w3m -dump -cols 64 -T text/html -O utf-8
282 directives is to insert the directives before
284 is run, which is typically done by entering
286 at the \*(lqWhat now?\*(rq prompt, or with an
290 These (optional) setup steps can make the convert support
296 program is installed on your system, it will be set by default
299 to filter the converter output.
303 environment variable, as described in its man page.
306 Add this line to your profile:
308 mhbuild-next: $EDITOR
310 assuming that your EDTIOR environment variable is set; if not, replace
311 EDITOR with the name of your editor.
312 Without that profile entry, a
313 response of \*(lqe[dit]\*(rq at the What now? prompt will require
314 specification of your editor if an
322 source the Bourne-shell compatible functions in
323 .IR %docdir%/contrib/replaliases .
325 That script also sets the
327 environment variable if it was not set.
329 .SS "Translating the Composition File"
331 is essentially a filter to aid in the composition of MIME
336 \*(lqcomposition file\*(rq
337 into a valid MIME message.
340 \*(lqcomposition file\*(rq
341 is just a file containing plain text that is interspersed
345 When this file is processed
348 the various directives will be expanded to the
349 appropriate content, and will be encoded according to the MIME standards.
350 The resulting MIME message can then be sent by electronic mail.
352 The formal syntax for a
354 composition file is defined at the
355 end of this document, but the ideas behind this format are not complex.
356 Basically, the body contains one or more contents.
357 A content consists of
358 either a directive, indicated with a \*(lq#\*(rq as the first character
359 of a line; or, plaintext (one or more lines of text).
361 character, \*(lq\\\*(lq, may be used to enter a single directive on more
367 /home/foobar/junk/picture.png
371 There are five kinds of directives: \*(lqtype\*(rq directives, which
372 name the type and subtype of the content; \*(lqexternal-type\*(rq
373 directives, which also name the type and subtype of the content; the
374 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
375 more messages; the \*(lqbegin\*(rq directive (#begin), which is
376 used to create a multipart content; and the \*(lqon/off/pop\*(rq
377 directives (#on, #off, #pop) which control whether any other
378 directives are honored at all.
382 switch allows control over whether mhbuild will honor any of the
383 \*(lq#\*(rq-directives.
384 This can also be affected with the #on or
385 #off directives, and #pop, which restores the state of processing to
386 that preceding the most recent #on or #off.
387 (The #on, #off, and #pop
388 directives are always honored, of course.) This allows inclusion of
389 plain text which looks like mhbuild directives, without causing
396 printf("Hello, World!");
401 Currently the stack depth for the #on/off/pop directives is 32.
403 The \*(lqtype\*(rq directive is used to directly specify the type and
404 subtype of a content.
405 You may only specify discrete types in this manner
406 (can't specify the types multipart or message with this directive).
407 You may optionally specify the name of a file containing the contents
408 in \*(lqnative\*(rq (decoded) format.
409 If this filename starts with the
410 \*(lq|\*(rq character, then it represents a command to execute whose
411 output is captured accordingly.
416 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
420 If a filename is not given,
422 will look for information in the
423 user's profile to determine how the different contents should be composed.
424 This is accomplished by consulting a composition string, and executing
427 with the standard output set to the content.
432 will echo any commands that are used to create contents in this way.
434 The composition string may contain the following escapes:
439 Insert parameters from directive
441 Insert filename containing content
443 %f, and stdout is not re-directed
445 Insert content subtype
453 will look for an entry of the form:
456 .BI mhbuild-compose- type / subtype
459 to determine the command to use to compose the content.
463 will look for an entry of the form:
466 .BI mhbuild-compose- type
469 to determine the composition command.
474 An example entry might be:
477 mhbuild-compose-audio/basic: record | raw2audio -F
480 Because commands like these will vary, depending on the display
481 environment used for login, composition strings for different
482 contents should probably be put in the file specified by the
484 environment variable, instead of directly in your
487 The \*(lqexternal-type\*(rq directives are used to provide a MIME
488 reference to a content, rather than enclosing the contents itself
489 (for instance, by specifying an ftp site).
491 providing a filename as with the type directives, external-parameters
493 These look like regular parameters, so they must be
494 separated accordingly.
499 #@application/octet-stream; \\
501 conversions=compress \\
502 [this is the nmh distribution] \\
503 {attachment; filename="nmh.tar.gz"} \\
504 name="nmh.tar.gz"; \\
505 directory="/pub/nmh"; \\
506 site="ftp.math.gatech.edu"; \\
507 access-type=anon-ftp; \\
512 You must give a description string to separate the content parameters
513 from the external-parameters (although this string may be empty).
514 This description string is specified by enclosing it within
516 A disposition string, to appear in a
517 \*(lqContent-Disposition\*(rq header, may appear in the optional
520 These parameters are of the form:
524 .ta \w'access-type= 'u
525 access-type= usually \*(lqanon-ftp\*(rq, \*(lqmail-server\*(rq, or \*(lqurl\*(rq
527 permission= read-only or read-write
529 directory= directoryname (optional)
530 mode= usually \*(lqascii\*(rq or \*(lqimage\*(rq (optional)
531 size= number of octets
533 subject= subject to send
534 body= command to send for retrieval
539 A minimum \*(lqexternal\-type\*(rq directive for the
546 #@application/octet-stream [] access-type=url; \\
547 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
551 Any long URLs will be wrapped according to RFC 2231 rules.
553 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
554 group of messages to include.
555 You may optionally specify the name of
556 the folder and which messages are to be forwarded.
558 given, it defaults to the current folder.
559 Similarly, if a message is not
560 given, it defaults to the current message.
561 Hence, the message directive
564 command, except that the former uses
565 the MIME rules for encapsulation rather than those specified in RFC 934.
570 #forw +inbox 42 43 99
574 If you include a single message, it will be included directly as a content
575 of type \*(lqmessage/rfc822\*(rq.
576 If you include more than one message,
579 will add a content of type \*(lqmultipart/digest\*(rq
580 and include each message as a subpart of this content.
582 If you are using this directive to include more than one message, you
586 This switch will indicate that
588 should attempt to utilize the MIME encapsulation rules
589 in such a way that the \*(lqmultipart/digest\*(rq that is created
590 is (mostly) compatible with the encapsulation specified in RFC 934.
591 If given, then RFC 934 compliant user-agents should be able to burst the
592 message on reception\0--\0providing that the messages being encapsulated
593 do not contain encapsulated messages themselves.
595 approach is that the encapsulations are generated by placing an extra
596 newline at the end of the body of each message.
598 The \*(lqbegin\*(rq directive is used to create a multipart content.
599 When using the \*(lqbegin\*(rq directive, you must specify at least one
600 content between the begin and end pairs.
605 This will be a multipart with only one part.
610 If you use multiple directives in a composition draft,
613 automatically encapsulate them inside a multipart content.
615 \*(lqbegin\*(rq directive is only necessary if you wish to use nested
616 multiparts, or create a multipart message containing only one part.
618 For all of these directives, the user may include a brief description
619 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
621 This description will be copied into the
622 \*(lqContent-Description\*(rq header when the directive is processed.
626 #forw [important mail from Bob] +bob 1 2 3 4 5
630 Similarly, a disposition string may optionally be provided between
631 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
632 \*(lqContent-Disposition\*(rq header when the directive is processed.
633 If a disposition string is provided that does not contain a filename
634 parameter, and a filename is provided in the directive, it will be
635 added to the \*(lqContent-Disposition\*(rq header.
641 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
645 creates these message part headers:
649 Content-Type: text/plain; charset="iso-8859-1"
650 Content-Disposition: attachment; filename="summary.txt"
656 will generate a unique \*(lqContent-ID:\*(rq for each directive,
657 corresponding to each message part; however, the user may override
658 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
662 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
663 even in the top level of the message.
667 will choose an appropriate Content\-Transfer\-Encoding based on the content
668 and the MIME Content\-Type.
669 However, you can override that in an
671 directive by specifying \*(lq*\*(rq and the encoding.
673 values are \*(lq8bit\*(rq, \*(lqqp\*(rq (for quoted\-printable), and
674 \*(lqb64\*(rq (for base64 encoding).
675 It should be noted that undesired
676 results may occur if 8bit or quoted\-printable is selected for binary
677 content, due to the translation between Unix line endings and the line
678 endings use by the mail transport system.
680 In addition to the various directives, plaintext can be present.
681 Plaintext is gathered, until a directive is found or the draft is
682 exhausted, and this is made to form a text content.
684 must contain a \*(lq#\*(rq at the beginning of a line, simply double it,
688 ##when sent, this line will start with only one #
691 If you want to end the plaintext prior to a directive, e.g., to have two
692 plaintext contents adjacent, simply insert a line containing a single
693 \*(lq#\*(rq character, e.g.,
697 this is the first content
699 and this is the second
703 Finally, if the plaintext starts with a line of the form:
706 Content-Description: text
709 then this will be used to describe the plaintext content.
710 You MUST follow this line with a blank line before starting
713 By default, plaintext is captured as a text/plain content.
715 override this by starting the plaintext with \*(lq#<\*(rq followed by
716 a content-type specification.
722 this content will be tagged as text/enriched
724 and this content will be tagged as text/plain
726 #<application/x-patch [this is a patch]
727 and this content will be tagged as application/x-patch
731 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
732 content-description must be on the same line which identifies the content
733 type of the plaintext.
735 When composing a text content, you may indicate the relevant character
736 set by adding the \*(lqcharset\*(rq parameter to the directive.
739 #<text/plain; charset=iso-8859-5
742 If a text content contains any 8\-bit characters (characters with the
743 high bit set) and the character set is not specified as above, then
745 will assume the character set is of the type given by the
748 environment variables.
749 If these environment variables are not
750 set, then the character set will be labeled as \*(lqx-unknown\*(rq.
752 If a text content contains only 7\-bit characters and the character set
753 is not specified as above, then the character set will be labeled as
756 By default text content with the high bit set is encoded with a 8bit
757 Content\-Transfer\-Encoding.
758 If the text has lines longer than the value
761 (which defaults to 78) then the text is encoded using the quoted\-printable
766 switch will indicate which algorithm to use when encoding any message headers
767 that contain 8\-bit characters.
768 The valid arguments are
770 for base\-64 encoding,
772 for quoted\-printable encoding, and
774 which requires that all 8\-bit header field bodies be encoded as UTF\-8
775 (RFC 6530) and that the message be sent to a SMTP server that supports
778 .B \-autoheaderencoding
781 to automatically pick the encoding, either base64 or quoted\-printable,
782 that results in a shorter encoded string.
784 Putting this all together,
785 here is an example of a more complicated message draft.
787 following draft will expand into a multipart/mixed message
788 containing five parts:
792 To: nobody@nowhere.org
794 Subject: Look and listen to me!
796 The first part will be text/plain
798 The second part will be text/enriched
800 This third part will be text/plain
801 #audio/basic [silly giggle] \\
802 |raw2audio -F < /usr/lib/sounds/giggle.au
803 #image/gif [photo of foobar] \\
804 /home/foobar/lib/picture.gif
807 .SS "Integrity Check"
812 switch, then it will also associate an integrity check with each
813 \*(lqleaf\*(rq content.
814 This will add a Content-MD5 header field to
815 the content, along with the md5 sum of the unencoded contents, per RFC
817 This may be used by the receiver of the message to verify that
818 the contents of the message were not changed in transport.
819 .SS "Transfer Encodings"
822 constructs the new MIME message by parsing directives,
823 including files, etc., it scans the contents of the message to determine
824 which transfer encoding to use.
825 It will check for 8bit data, long lines,
826 spaces at the end of lines, and clashes with multipart boundaries.
828 then choose a transfer encoding appropriate for each content type.
830 If an integrity check is being associated with each content by using
835 will encode each content with
836 a transfer encoding, even if the content contains only 7\-bit data.
838 is to increase the likelihood that the content is not changed while in
840 .SS "Invoking mhbuild"
847 command will expect the body of the draft to be formatted as an
850 Once you have composed this input file
851 using a command such as
858 at the \*(lqWhat now\*(rq prompt with
864 prior to sending the draft.
869 to translate the composition file into MIME format.
871 Normally it is an error to invoke
873 on file that already in MIME format.
878 to exit without error if the input file already has valid MIME headers.
885 Finally, you should consider adding this line to your profile:
891 This way, if you decide to
901 will work as you expect.
905 switch is intended to be used by
907 It will cause mhbuild to not generate any MIME headers in the composition
908 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
909 will still encode message headers according to RFC 2047.
910 .SS "User Environment"
911 Because the environment in which
913 operates may vary for a
916 will look for the environment variable
918 If present, this specifies the name of an additional user profile which
920 Hence, when a user logs in on a particular machine,
921 this environment variable should be set to refer to a file containing
922 definitions useful for that machine.
926 will attempt to consult
929 %nmhetcdir%/mhn.defaults
934 See "Profile Lookup" in
936 for the profile search order, and for how duplicate entries are treated.
937 .SS "Syntax of Composition Files"
938 The following is the formal syntax of a
940 \*(lqcomposition file\*(rq.
944 body ::= 1*(content | EOL)
946 content ::= directive | plaintext
948 directive ::= "#" type "/" subtype
949 0*(";" attribute "=" value)
952 [ "[" description "]" ]
953 [ "{" disposition "}" ]
954 [ "*8bit" | "*qp" | "*b64" ]
958 | "#@" type "/" subtype
959 0*(";" attribute "=" value)
962 [ "[" description "]" ]
963 [ "{" disposition "}" ]
964 [ "*8bit" | "*qp" | "*b64" ]
970 [ "[" description "]" ]
971 [ "{" disposition "}" ]
972 [ "+"folder ] [ 0*msg ]
977 [ "[" description "]" ]
978 [ "{" disposition "}" ]
986 plaintext ::= [ "Content-Description:"
987 description EOL EOL ]
991 | "#<" type "/" subtype
992 0*(";" attribute "=" value)
994 [ "[" description "]" ]
995 [ "{" disposition "}" ]
996 [ "*8bit" | "*qp" | "*b64" ]
1001 line ::= "##" text EOL
1002 -- interpreted as "#"text EOL
1008 looks for additional user profile files and
1011 locations: absolute pathnames are accessed directly, tilde expansion
1012 is done on usernames, and files are searched for in the user's
1014 directory as specified in their profile.
1015 If not found there, the directory
1016 .RI \*(lq %nmhetcdir% \*(rq
1021 $HOME/\&.mh\(ruprofile
1025 Additional profile entries.
1027 %nmhetcdir%/mhn.defaults
1028 System default MIME profile entries.
1030 .SH "PROFILE COMPONENTS"
1034 To determine the user's nmh directory.
1037 To find the default current folder.
1039 .RI mhbuild-compose- type* :
1040 Template for composing contents.
1047 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
1050 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
1053 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
1056 .I "Internet Message Format"
1059 .I "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"
1062 .I "Proposed Standard for Message Encapsulation"
1065 .I "The Content-MD5 Header Field"
1068 .I "Definition of the URL MIME External-Body Access-Type"
1071 .I "Overview and Framework for Internationalized Email"
1074 .I "SMTP Extension for Internationalized Email"
1078 \-autoheaderencoding