]> diplodocus.org Git - nmh/blob - man/mhbuild.man
mhlsbr.c: Don't strchr(3) non-string NUL-less buffer.
[nmh] / man / mhbuild.man
1 .TH MHBUILD %manext1% 2016-10-15 "%nmhversion%"
2 .
3 .\" %nmhwarning%
4 .
5 .SH NAME
6 mhbuild \- translate MIME composition drafts for nmh messages
7 .SH SYNOPSIS
8 .na
9 .HP 5
10 .B mhbuild
11 .RB [ \-help ]
12 .RB [ \-version ]
13 .I file
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 .I encoding-algorithm
26 .RB " | " \-autoheaderencoding ]
27 .RB [ \-maxunencoded
28 .IR line-length ]
29 .RB [ \-dist ]
30 .ad
31 .SH DESCRIPTION
32 The
33 .B mhbuild
34 command will translate a MIME composition draft into a valid MIME message.
35 .PP
36 .B mhbuild
37 creates multi-media messages as specified in RFCs 2045 through 2049.
38 This includes the encoding of message headers as specified by RFC 2047,
39 and, additionally, the encoding of MIME parameters as specified in RFC 2231.
40 .PP
41 If you specify the name of the composition file as \*(lq-\*(rq, then
42 .B mhbuild
43 will accept the composition draft on the standard input.
44 If the translation of this input is successful,
45 .B mhbuild
46 will output the new MIME message to the standard output.
47 This argument must be the last argument on the command line.
48 .PP
49 Otherwise, if the file argument to
50 .B mhbuild
51 is the name of a valid composition file, and the translation is successful,
52 .B mhbuild
53 will replace the original file with the new MIME message.
54 It will rename the original file to start with the \*(lq,\*(rq character
55 and end with the string \*(lq.orig\*(rq, e.g., if you are editing the file
56 \*(lqdraft\*(rq, it will be renamed to \*(lq,draft.orig\*(rq.
57 This allows you to easily recover the
58 .B mhbuild
59 input file.
60 .SS "Listing the Contents"
61 The
62 .B \-list
63 switch tells
64 .B mhbuild
65 to list the table of contents associated with the MIME message that is created.
66 .PP
67 The
68 .B \-headers
69 switch indicates that a one-line banner should be displayed above the listing.
70 The
71 .B \-realsize
72 switch tells
73 .B mhbuild
74 to evaluate the \*(lqnative\*(rq (decoded) format of each content prior to listing.
75 This provides an accurate count at the expense of a small delay.
76 If the
77 .B \-verbose
78 switch
79 is present, then the listing will show any \*(lqextra\*(rq information
80 that is present in the message, such as comments in the
81 \*(lqContent-Type\*(rq header.
82 .PP
83 If the
84 .B \-disposition
85 switch is present, then the listing will show any relevant information from
86 the \*(lqContent-Disposition\*(rq header.
87 .SS "Simplified Attachment Interface"
88 For users who wish to simply attach files to text content,
89 .B mhbuild
90 will scan the composition file for \*(lqAttach\*(rq headers.
91 An \*(lqAttach\*(rq header contains a filename that will be appended to the
92 message using normal MIME encapsulation rules. One filename is allowed
93 per \*(lqAttach\*(rq header, but multiple \*(lqAttach\*(rq headers are
94 allowed per composition file.
95 .PP
96 These files will be appended after any other MIME content, including any
97 content specified by
98 .B mhbuild
99 directives (see below). See
100 .IR send (1)
101 for more details.
102 .PP
103 By default, the Content-Disposition will be \*(lqattachment\*(rq.
104 .B mhbuild
105 looks for user profile and
106 .I mhn.defaults
107 entries of the form
108 .PP
109 .RS 5
110 .BI mhbuild-disposition- type / subtype
111 .RE
112 or
113 .RS 5
114 .BI mhbuild-disposition- type
115 .RE
116 .PP
117 to supply the disposition value. The only supported values are
118 \*(lqattachment\*(rq
119 and
120 \*(lqinline\*(rq.
121 .SS "Convert Interface"
122 The convert interface is a powerful mechanism that supports
123 replying to MIME messages.
124 These placeholders are used in the following description:
125 .RS 5
126 .TP 15
127 .PD 0
128 TYPE
129 content type/subtype
130 .TP
131 CONVERTER
132 external program, and any fixed arguments, to convert content, such as
133 from a request to a reply
134 .TP
135 ARGSTRING
136 arguments to pass from
137 .B repl
138 to
139 .I CONVERTER
140 .TP
141 FILE
142 full path of message being replied to
143 .PD
144 .RE
145 The convert support is based on pseudoheaders of the form
146 .PP
147 .RS 5
148 .nf
149 .BI Nmh-mhbuild-file- TYPE : \0FILE
150 .BI Nmh-mhbuild-args- TYPE : \0ARGSTRING
151 .fi
152 .RE
153 .PP
154 in the draft.
155 For each such pseudoheader, mhbuild looks in the profile and
156 .I mhn.defaults
157 for the corresponding
158 .I TYPE
159 entry to find the converter that supports it:
160 .PP
161 .RS 5
162 .BI mhbuild-convert- TYPE : \0CONVERTER
163 .RE
164 .PP
165 It's a fatal error if no such entry is found for
166 .IR TYPE .
167 An empty entry, e.g.,
168 .PP
169 .RS 5
170 .B mhbuild-convert-text/html:
171 .RE
172 .PP
173 excludes parts of that
174 .I TYPE
175 from the draft.
176 .PP
177 The
178 .I mhn.defaults
179 file contains default
180 .B mhbuild-convert-text/html
181 and
182 .B mhbuild-convert-text/plain
183 entries. Profile entries can be used to override corresponding
184 .I mhn.defaults
185 entries, as usual. Text converters should limit text line lengths
186 to a maximum of 78 characters, and must limit them to a maximum of 998
187 characters, per RFC 5322 Sec.\& 2.1.1.
188 .PP
189 For each
190 .I TYPE
191 part in
192 .IR FILE ,
193 .B mhbuild
194 runs
195 .I CONVERTER ARGSTRING
196 on the content of the part.
197 Each part in
198 .I FILE
199 that has no corresponding TYPE entry in the profile or
200 .I mhn.defaults
201 is
202 excluded from the draft; the user can include them using mhbuild directives.
203 .PP
204 .B repl
205 inserts
206 .B Nmh-mhbuild-text/html:
207 and
208 .B Nmh-mhbuild-text/plain:
209 pseudoheaders in every draft. The user can prevent insertion of
210 content parts of either of those types by putting corresponding empty
211 entries in their profile.
212 .PP
213 Only the highest precedence alternative with a supported
214 .I TYPE
215 of a multipart/alternative part is used.
216 .PP
217 mhn.defaults.sh selects the text/html-to-text/plain converter at
218 install time. It includes
219 .B iconv
220 and
221 .BR par ,
222 or
223 .BR fmt ,
224 in the pipeline only if they are found.
225 .PP
226 Some content types require the addition of parameters to the
227 Content-Type header, such as \*(lqmethod=REPLY\*(rq
228 for text/calendar.
229 .B mhbuild
230 looks for a Content-Type header, followed
231 by a blank line, at the beginning of the converter output.
232 If one is found, it is used for the corresponding part in the reply draft.
233 .PP
234 The convert interface doesn't support different
235 .IR ARGSTRING s
236 or different converters for different parts of the same
237 .IR TYPE .
238 That would require associating parts by part number with the
239 .IR ARGSTRING s
240 or converters. Instead, that can be done (currently, without using
241 the convert support), with
242 .B mhbuild
243 directives as described below, e.g.,
244 .PP
245 .RS 5
246 #text/html; charset=utf-8 *8bit | mhstore -noverbose -part 42.7 -outfile - | w3m -dump -cols 64 -T text/html -O utf-8
247 .RE
248 .PP
249 The only way to mix convert pseudoheaders and
250 .B mhbuild
251 directives is to insert the directives before
252 .B mhbuild
253 is run, which is typically done by entering
254 .I mime
255 at the \*(lqWhat now?\*(rq prompt, or with an
256 .B \-editor mhbuild
257 switch.
258 .PP
259 These (optional) setup steps can make the convert support
260 easier to use:
261 .TP 5
262 1)
263 If the
264 .B par
265 program is installed on your system, it will be set by default
266 (in
267 .IR mhn.defaults )
268 to filter the converter output. It helps to set the PARINIT
269 environment variable, as described in
270 .IR par (1).
271 .TP 5
272 2)
273 Add this line to your profile:
274 .IP "" 10
275 mhbuild-next: $EDITOR
276 .IP "" 5
277 assuming that your EDITOR environment variable is set; if not, replace
278 EDITOR with the name of your editor. Without that profile entry, a
279 response of \*(lqe[dit]\*(rq at the What now? prompt will require
280 specification of your editor if an
281 .B \-editor mhbuild
282 switch is used.
283 .TP 5
284 3)
285 If using
286 .BR repl ,
287 source the Bourne-shell compatible functions in
288 .IR %docdir%/contrib/replaliases .
289 .br
290 That script also sets the PARINIT environment variable if it was not set.
291 .SS "Translating the Composition File"
292 .B mhbuild
293 is essentially a filter to aid in the composition of MIME messages.
294 .B mhbuild
295 will convert an
296 .B mhbuild
297 \*(lqcomposition file\*(rq into a valid MIME message.
298 An
299 .B mhbuild
300 \*(lqcomposition file\*(rq is just a file containing plain text that is
301 interspersed with various
302 .B mhbuild
303 directives. When this file is processed by
304 .BR mhbuild ,
305 the various directives will be expanded to the appropriate content, and
306 will be encoded according to the MIME standards.
307 The resulting MIME message can then be sent by electronic mail.
308 .PP
309 The formal syntax for a
310 .B mhbuild
311 composition file is defined at the end of this document, but the ideas
312 behind this format are not complex.
313 Basically, the body contains one or more contents. A content consists of
314 either a directive, indicated with a \*(lq#\*(rq as the first character
315 of a line; or, plaintext (one or more lines of text).
316 The continuation character, \*(lq\\\*(lq, may be used to enter a single
317 directive on more than one line, e.g.,
318 .PP
319 .RS 5
320 .nf
321 #image/png \\
322 /home/foobar/junk/picture.png
323 .fi
324 .RE
325 .PP
326 There are five kinds of directives: \*(lqtype\*(rq directives, which
327 name the type and subtype of the content; \*(lqexternal-type\*(rq
328 directives, which also name the type and subtype of the content; the
329 \*(lqmessage\*(rq directive (#forw), which is used to forward one or
330 more messages; the \*(lqbegin\*(rq directive (#begin), which is
331 used to create a multipart content; and the \*(lqon/off/pop\*(rq
332 directives (#on, #off, #pop) which control whether any other
333 directives are honored at all.
334 .PP
335 The
336 .B \-directives
337 switch allows control over whether mhbuild will honor any of the
338 \*(lq#\*(rq-directives.
339 This can also be affected with the #on or #off directives, and #pop,
340 which restores the state of processing to that preceding the most recent
341 #on or #off. (The #on, #off, and #pop directives are always honored,
342 of course.) This allows inclusion of plain text which looks like mhbuild
343 directives, without causing errors:
344 .PP
345 .RS 5
346 .nf
347 #off
348 #include <stdio.h>
349 printf("Hello, World!");
350 #pop
351 .fi
352 .RE
353 .PP
354 Currently the stack depth for the #on/off/pop directives is 32.
355 .PP
356 The \*(lqtype\*(rq directive is used to directly specify the type and
357 subtype of a content. You may only specify discrete types in this manner
358 (can't specify the types multipart or message with this directive).
359 You may optionally specify the name of a file containing the contents
360 in \*(lqnative\*(rq (decoded) format.
361 If this filename starts with the \*(lq|\*(rq character, then it represents
362 a command to execute whose output is captured accordingly.
363 For example,
364 .PP
365 .RS 5
366 .nf
367 #audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
368 .fi
369 .RE
370 .PP
371 If a filename is not given,
372 .B mhbuild
373 will look for information in the
374 user's profile to determine how the different contents should be composed.
375 This is accomplished by consulting a composition string, and executing
376 it under
377 .BR /bin/sh ,
378 with the standard output set to the content. If the
379 .B \-verbose
380 switch is given,
381 .B mhbuild
382 will echo any commands that are used to create contents in this way.
383 .PP
384 The composition string may contain the following escapes:
385 .PP
386 .RS 5
387 .PD 0
388 .IP %a
389 Insert parameters from directive
390 .IP %f
391 Insert filename containing content
392 .IP %F
393 %f, and stdout is not re-directed
394 .IP %s
395 Insert content subtype
396 .IP %%
397 Insert character %
398 .PD
399 .RE
400 .PP
401 First,
402 .B mhbuild
403 will look for an entry of the form:
404 .PP
405 .RS 5
406 .BI mhbuild-compose- type / subtype
407 .RE
408 .PP
409 to determine the command to use to compose the content.
410 If this isn't found,
411 .B mhbuild
412 will look for an entry of the form:
413 .PP
414 .RS 5
415 .BI mhbuild-compose- type
416 .RE
417 .PP
418 to determine the composition command. If this isn't found,
419 .B mhbuild
420 will complain.
421 .PP
422 An example entry might be:
423 .PP
424 .RS 5
425 mhbuild-compose-audio/basic: record | raw2audio -F
426 .RE
427 .PP
428 Because commands like these will vary, depending on the display
429 environment used for login, composition strings for different
430 contents should probably be put in the file specified by the
431 MHBUILD environment variable, instead of directly in your
432 user profile.
433 .PP
434 The \*(lqexternal-type\*(rq directives are used to provide a MIME
435 reference to a content, rather than enclosing the contents itself
436 (for instance, by specifying an ftp site).
437 Hence, instead of providing a filename as with the type directives,
438 external-parameters are supplied.
439 These look like regular parameters, so they must be separated accordingly.
440 For example,
441 .PP
442 .RS 5
443 .nf
444 #@application/octet-stream; \\
445 type=tar; \\
446 conversions=compress \\
447 [this is the nmh distribution] \\
448 {attachment; filename="nmh.tar.gz"} \\
449 name="nmh.tar.gz"; \\
450 directory="/pub/nmh"; \\
451 site="ftp.math.gatech.edu"; \\
452 access-type=anon-ftp; \\
453 mode="image"
454 .fi
455 .RE
456 .PP
457 You must give a description string to separate the content parameters
458 from the external-parameters (although this string may be empty).
459 This description string is specified by enclosing it within
460 \*(lq[]\*(rq.
461 A disposition string, to appear in a
462 \*(lqContent-Disposition\*(rq header, may appear in the optional
463 \*(lq{}\*(rq.
464 .PP
465 These parameters are of the form:
466 .PP
467 .RS 5
468 .nf
469 .ta \w'access-type= 'u
470 access-type= usually \*(lqanon-ftp\*(rq, \*(lqmail-server\*(rq, or \*(lqurl\*(rq
471 name= filename
472 permission= read-only or read-write
473 site= hostname
474 directory= directoryname (optional)
475 mode= usually \*(lqascii\*(rq or \*(lqimage\*(rq (optional)
476 size= number of octets
477 server= mailbox
478 subject= subject to send
479 body= command to send for retrieval
480 url= URL of content
481 .fi
482 .RE
483 .PP
484 A minimum \*(lqexternal\-type\*(rq directive for the
485 .B url
486 .I access-type
487 would be as follows:
488 .PP
489 .RS 3
490 .nf
491 #@application/octet-stream [] access-type=url; \\
492 url="http://download.savannah.gnu.org/releases/nmh/nmh-1.5.tar.gz"
493 .fi
494 .RE
495 .PP
496 Any long URLs will be wrapped according to RFC 2231 rules.
497 .PP
498 The \*(lqmessage\*(rq directive (#forw) is used to specify a message or
499 group of messages to include. You may optionally specify the name of
500 the folder and which messages are to be forwarded.
501 If a folder is not given, it defaults to the current folder.
502 Similarly, if a message is not given, it defaults to the current message.
503 Hence, the message directive is similar to the
504 .B forw
505 command, except that the former uses the MIME rules for encapsulation
506 rather than those specified in RFC 934.
507 For example,
508 .PP
509 .RS 5
510 .nf
511 #forw +inbox 42 43 99
512 .fi
513 .RE
514 .PP
515 If you include a single message, it will be included directly as a content
516 of type \*(lqmessage/rfc822\*(rq.
517 If you include more than one message, then
518 .B mhbuild
519 will add a content of type \*(lqmultipart/digest\*(rq
520 and include each message as a subpart of this content.
521 .PP
522 If you are using this directive to include more than one message, you
523 may use the
524 .B \-rfc934mode
525 switch. This switch will indicate that
526 .B mhbuild
527 should attempt to utilize the MIME encapsulation rules in such a way
528 that the \*(lqmultipart/digest\*(rq that is created is (mostly) compatible
529 with the encapsulation specified in RFC 934.
530 If given, then RFC 934 compliant user-agents should be able to burst the
531 message on reception\0--\0providing that the messages being encapsulated
532 do not contain encapsulated messages themselves.
533 The drawback of this approach is that the encapsulations are generated by
534 placing an extra newline at the end of the body of each message.
535 .PP
536 The \*(lqbegin\*(rq directive is used to create a multipart content.
537 When using the \*(lqbegin\*(rq directive, you must specify at least one
538 content between the begin and end pairs.
539 .PP
540 .RS 5
541 .nf
542 #begin
543 This will be a multipart with only one part.
544 #end
545 .fi
546 .RE
547 .PP
548 If you use multiple directives in a composition draft,
549 .B mhbuild
550 will automatically encapsulate them inside a multipart content.
551 Therefore the \*(lqbegin\*(rq directive is only necessary if you wish to
552 use nested multiparts, or create a multipart message containing only one part.
553 .PP
554 For all of these directives, the user may include a brief description
555 of the content between the \*(lq[\*(rq character and the \*(lq]\*(rq
556 character.
557 This description will be copied into the \*(lqContent-Description\*(rq header
558 when the directive is processed.
559 .PP
560 .RS 5
561 .nf
562 #forw [important mail from Bob] +bob 1 2 3 4 5
563 .fi
564 .RE
565 .PP
566 Similarly, a disposition string may optionally be provided between
567 \*(lq{\*(rq and \*(lq}\*(rq characters; it will be copied into the
568 \*(lqContent-Disposition\*(rq header when the directive is processed.
569 If a disposition string is provided that does not contain a filename
570 parameter, and a filename is provided in the directive, it will be
571 added to the \*(lqContent-Disposition\*(rq header.
572 For example, the following directive:
573 .PP
574 .RS 5
575 .nf
576 #text/plain; charset=iso-8859-1 <>{attachment} /tmp/summary.txt
577 .fi
578 .RE
579 .PP
580 creates these message part headers:
581 .PP
582 .RS 5
583 .nf
584 Content-Type: text/plain; charset="iso-8859-1"
585 Content-Disposition: attachment; filename="summary.txt"
586 .fi
587 .RE
588 .PP
589 By default,
590 .B mhbuild
591 will generate a unique \*(lqContent-ID:\*(rq for each directive,
592 corresponding to each message part; however, the user may override
593 this by defining the ID using the \*(lq<\*(rq and \*(lq>\*(rq
594 characters. The
595 .B \-nocontentid
596 switch suppresses creation of all \*(lqContent-ID:\*(rq headers,
597 even in the top level of the message.
598 .PP
599 Normally
600 .B mhbuild
601 will choose an appropriate Content\-Transfer\-Encoding based on the content
602 and the MIME Content\-Type.
603 However, you can override that in an
604 .B mhbuild
605 directive by specifying \*(lq*\*(rq and the encoding.
606 Acceptable encoding values are \*(lq8bit\*(rq, \*(lqqp\*(rq
607 (for quoted-printable), and \*(lqb64\*(rq (for base64 encoding).
608 It should be noted that undesired results may occur if 8bit or quoted-printable
609 is selected for binary content, due to the translation between Unix line endings
610 and the line endings use by the mail transport system.
611 .PP
612 In addition to the various directives, plaintext can be present.
613 Plaintext is gathered, until a directive is found or the draft is
614 exhausted, and this is made to form a text content.
615 If the plaintext must contain a \*(lq#\*(rq at the beginning of a line,
616 simply double it,
617 e.g.,
618 .PP
619 .RS 5
620 ##when sent, this line will start with only one #
621 .RE
622 .PP
623 If you want to end the plaintext prior to a directive, e.g., to have two
624 plaintext contents adjacent, simply insert a line containing a single
625 \*(lq#\*(rq character, e.g.,
626 .PP
627 .RS 5
628 .nf
629 this is the first content
630 #
631 and this is the second
632 .fi
633 .RE
634 .PP
635 Finally, if the plaintext starts with a line of the form:
636 .PP
637 .RS 5
638 Content-Description: text
639 .RE
640 .PP
641 then this will be used to describe the plaintext content.
642 You MUST follow this line with a blank line before starting your text.
643 .PP
644 By default, plaintext is captured as a text/plain content.
645 You can override this by starting the plaintext with \*(lq#<\*(rq followed
646 by a content-type specification. For example, e.g.,
647 .PP
648 .RS 5
649 .nf
650 #<text/enriched
651 this content will be tagged as text/enriched
652 #
653 and this content will be tagged as text/plain
654 #
655 #<application/x-patch [this is a patch]
656 and this content will be tagged as application/x-patch
657 .fi
658 .RE
659 .PP
660 Note that if you use the \*(lq#<\*(rq plaintext-form, then the
661 content-description must be on the same line which identifies the content
662 type of the plaintext.
663 .PP
664 When composing a text content, you may indicate the relevant character
665 set by adding the \*(lqcharset\*(rq parameter to the directive.
666 .PP
667 .RS 5
668 #<text/plain; charset=iso-8859-5
669 .RE
670 .PP
671 If a text content contains any 8-bit characters (characters with the
672 high bit set) and the character set is not specified as above, then
673 .B mhbuild
674 will assume the character set is of the type given by the standard
675 .IR locale (1)
676 environment variables.
677 If these environment variables are not set, then the character set
678 will be labeled as \*(lqx-unknown\*(rq.
679 .PP
680 If a text content contains only 7-bit characters and the character set
681 is not specified as above, then the character set will be labeled as
682 \*(lqus-ascii\*(rq.
683 .PP
684 By default text content with the high bit set is encoded with an 8-bit
685 Content-Transfer-Encoding.
686 If the text has lines longer than the value of
687 .B \-maxunencoded
688 (which defaults to 78) then the text is encoded using the quoted-printable
689 encoding.
690 .PP
691 The
692 .B \-headerencoding
693 switch will indicate which algorithm to use when encoding any message headers
694 that contain 8-bit characters.
695 The valid arguments are
696 .I base64
697 for base-64 encoding,
698 .I quoted
699 for quoted-printable encoding, and
700 .I utf\-8
701 which requires that all 8-bit header field bodies be encoded as UTF-8
702 (RFC 6530) and that the message be sent to a SMTP server that supports
703 SMTPUTF8 (RFC 6531).
704 The
705 .B \-autoheaderencoding
706 switch instructs
707 .B mhbuild
708 to automatically pick the encoding, either base64 or quoted-printable,
709 that results in a shorter encoded string.
710 .PP
711 Putting this all together, here is an example of a more complex message draft,
712 which will expand into a multipart/mixed message containing five parts:
713 .PP
714 .RS 5
715 .nf
716 To: nobody@nowhere.org
717 cc:
718 Subject: Look and listen to me!
719 --------
720 The first part will be text/plain
721 #<text/enriched
722 The second part will be text/enriched
723 #
724 This third part will be text/plain
725 #audio/basic [silly giggle] \\
726 |raw2audio -F < /usr/lib/sounds/giggle.au
727 #image/gif [photo of foobar] \\
728 /home/foobar/lib/picture.gif
729 .fi
730 .RE
731 .SS "Integrity Check"
732 If
733 .B mhbuild
734 is given the
735 .B \-check
736 switch, then it will also associate an integrity check with each
737 \*(lqleaf\*(rq content.
738 This will add a Content-MD5 header field to the content, along with the md5
739 sum of the unencoded contents, per RFC 1864.
740 This may be used by the receiver of the message to verify that the contents
741 of the message were not changed in transport.
742 .SS "Transfer Encodings"
743 After
744 .B mhbuild
745 constructs the new MIME message by parsing directives, including files, etc.,
746 it scans the contents of the message to determine which transfer encoding to use.
747 It will check for 8-bit data, long lines, spaces at the end of lines, and
748 clashes with multipart boundaries.
749 It will then choose a transfer encoding appropriate for each content type.
750 .PP
751 If an integrity check is being associated with each content by using
752 the
753 .B \-check
754 switch, then
755 .B mhbuild
756 will encode each content with
757 a transfer encoding, even if the content contains only 7-bit data.
758 This is to increase the likelihood that the content is not changed while in
759 transport.
760 .SS "Invoking mhbuild"
761 Typically,
762 .B mhbuild
763 is invoked by the
764 .B whatnow
765 program.
766 This command will expect the body of the draft to be formatted as an
767 .B mhbuild
768 composition file.
769 Once you have composed this input file using a command such as
770 .BR comp ,
771 .BR forw ,
772 or
773 .BR repl ,
774 you invoke
775 .B mhbuild
776 at the \*(lqWhat now\*(rq prompt with
777 .PP
778 .RS 5
779 What now? mime
780 .RE
781 .PP
782 prior to sending the draft.
783 This will cause
784 .B whatnow
785 to execute
786 .B mhbuild
787 to translate the composition file into MIME format.
788 .PP
789 Normally it is an error to invoke
790 .B mhbuild
791 on a file that is already in MIME format.
792 The
793 .B \-auto
794 switch will cause
795 .B mhbuild
796 to exit without error if the input file already has valid MIME headers.
797 The use of
798 .B \-auto
799 also enables the
800 .B \-nodirectives
801 switch.
802 .PP
803 Finally, you should consider adding this line to your profile:
804 .PP
805 .RS 5
806 lproc: show
807 .RE
808 .PP
809 This way, if you decide to
810 .B list
811 after invoking
812 .BR mime ,
813 the command
814 .PP
815 .RS 5
816 What now? list
817 .RE
818 .PP
819 will work as you expect.
820 .PP
821 The
822 .B \-dist
823 switch is intended to be used by
824 .BR dist .
825 It will cause mhbuild to not generate any MIME headers in the composition
826 file (such as \*(lqMIME-Version\*(rq or \*(lqContent-Type\*(rq), but it
827 will still encode message headers according to RFC 2047.
828 .SS "User Environment"
829 Because the environment in which
830 .B mhbuild
831 operates may vary for a user,
832 .B mhbuild
833 will look for the environment variable MHBUILD.
834 If present, this specifies the name of an additional user profile which
835 should be read.
836 Hence, when a user logs in on a particular machine, this environment
837 variable should be set to refer to a file containing definitions useful
838 on that machine.
839 .PP
840 Finally,
841 .B mhbuild
842 will attempt to consult
843 .PP
844 .RS 5
845 %nmhetcdir%/mhn.defaults
846 .RE
847 .PP
848 if it exists.
849 .PP
850 See "Profile Lookup" in
851 .IR mh-profile (5)
852 for the profile search order, and for how duplicate entries are treated.
853 .SS "Syntax of Composition Files"
854 The following is the formal syntax of a
855 .B mhbuild
856 \*(lqcomposition file\*(rq.
857 .PP
858 .RS 5
859 .nf
860 body ::= 1*(content | EOL)
861
862 content ::= directive | plaintext
863
864 directive ::= "#" type "/" subtype
865 0*(";" attribute "=" value)
866 [ "(" comment ")" ]
867 [ "<" id ">" ]
868 [ "[" description "]" ]
869 [ "{" disposition "}" ]
870 [ "*8bit" | "*qp" | "*b64" ]
871 [ filename ]
872 EOL
873
874 | "#@" type "/" subtype
875 0*(";" attribute "=" value)
876 [ "(" comment ")" ]
877 [ "<" id ">" ]
878 [ "[" description "]" ]
879 [ "{" disposition "}" ]
880 [ "*8bit" | "*qp" | "*b64" ]
881 external-parameters
882 EOL
883
884 | "#forw"
885 [ "<" id ">" ]
886 [ "[" description "]" ]
887 [ "{" disposition "}" ]
888 [ "+"folder ] [ 0*msg ]
889 EOL
890
891 | "#begin"
892 [ "<" id ">" ]
893 [ "[" description "]" ]
894 [ "{" disposition "}" ]
895 [ "alternative"
896 | "parallel"
897 | something-else ]
898 EOL
899 1*body
900 "#end" EOL
901
902 plaintext ::= [ "Content-Description:"
903 description EOL EOL ]
904 1*line
905 [ "#" EOL ]
906
907 | "#<" type "/" subtype
908 0*(";" attribute "=" value)
909 [ "(" comment ")" ]
910 [ "[" description "]" ]
911 [ "{" disposition "}" ]
912 [ "*8bit" | "*qp" | "*b64" ]
913 EOL
914 1*line
915 [ "#" EOL ]
916
917 line ::= "##" text EOL
918 -- interpreted as "#"text EOL
919 | text EOL
920 .fi
921 .RE
922 .SH FILES
923 .B mhbuild
924 looks for additional user profile files and
925 .I mhn.defaults
926 in multiple locations: absolute pathnames are accessed directly, tilde
927 expansion is done on usernames, and files are searched for in the user's
928 .I Mail
929 directory as specified in their profile.
930 If not found there, the directory
931 .RI \*(lq %nmhetcdir% \*(rq
932 is checked.
933 .PP
934 .PD 0
935 .TP 20
936 $HOME/.mh_profile
937 The user's profile.
938 .TP
939 $MHBUILD
940 Additional profile entries.
941 .TP
942 %nmhetcdir%/mhn.defaults
943 System default MIME profile entries.
944 .PD
945 .SH "PROFILE COMPONENTS"
946 .PD 0
947 .TP 20
948 Path:
949 To determine the user's nmh directory.
950 .TP
951 Current\-Folder:
952 To find the default current folder.
953 .TP
954 .RI mhbuild-compose- type* :
955 Template for composing contents.
956 .PD
957 .SH "SEE ALSO"
958 .IR mhlist (1),
959 .IR mhshow (1),
960 .IR mhstore (1)
961 .PP
962 .I "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies"
963 (RFC 2045)
964 .PP
965 .I "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types"
966 (RFC 2046)
967 .PP
968 .I "Multipurpose Internet Mail Extensions (MIME) Part Three: Message Header Extensions for Non-ASCII Text"
969 (RFC 2047)
970 .PP
971 .I "Internet Message Format"
972 (RFC 5322)
973 .PP
974 .I "MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations"
975 (RFC 2231)
976 .PP
977 .I "Proposed Standard for Message Encapsulation"
978 (RFC 934)
979 .PP
980 .I "The Content-MD5 Header Field"
981 (RFC 1864)
982 .PP
983 .I "Definition of the URL MIME External-Body Access-Type"
984 (RFC 2017)
985 .PP
986 .I "Overview and Framework for Internationalized Email"
987 (RFC 6530)
988 .PP
989 .I "SMTP Extension for Internationalized Email"
990 (RFC 6531)
991 .SH DEFAULTS
992 .nf
993 \-autoheaderencoding
994 \-contentid
995 \-headers
996 \-maxunencoded 78
997 \-nocheck
998 \-nodisposition
999 \-norfc934mode
1000 \-noverbose
1001 \-realsize
1002 .fi