*** empty log message ***
[gnus] / texi / emacs-mime.texi
1 \input texinfo                  @c -*-texinfo-*-
2
3 @setfilename emacs-mime
4 @settitle Emacs MIME Manual
5 @synindex fn cp
6 @synindex vr cp
7 @synindex pg cp
8 @c @direntry
9 @c * Emacs MIME: (emacs-mime).   The MIME de/composition library.
10 @c @end direntry
11 @iftex
12 @finalout
13 @end iftex
14 @setchapternewpage odd
15
16 @ifinfo
17
18 This file documents the Emacs MIME interface functionality.
19
20 Copyright (C) 1996 Free Software Foundation, Inc.
21
22 Permission is granted to make and distribute verbatim copies of
23 this manual provided the copyright notice and this permission notice
24 are preserved on all copies.
25
26 @ignore
27 Permission is granted to process this file through Tex and print the
28 results, provided the printed document carries copying permission
29 notice identical to this one except for the removal of this paragraph
30 (this paragraph not being relevant to the printed manual).
31
32 @end ignore
33 Permission is granted to copy and distribute modified versions of this
34 manual under the conditions for verbatim copying, provided also that the
35 entire resulting derived work is distributed under the terms of a
36 permission notice identical to this one.
37
38 Permission is granted to copy and distribute translations of this manual
39 into another language, under the above conditions for modified versions.
40 @end ifinfo
41
42 @tex
43
44 @titlepage
45 @title Emacs MIME Manual
46
47 @author by Lars Magne Ingebrigtsen
48 @page
49
50 @vskip 0pt plus 1filll
51 Copyright @copyright{} 1998 Free Software Foundation, Inc. 
52
53 Permission is granted to make and distribute verbatim copies of
54 this manual provided the copyright notice and this permission notice
55 are preserved on all copies.
56
57 Permission is granted to copy and distribute modified versions of this
58 manual under the conditions for verbatim copying, provided that the
59 entire resulting derived work is distributed under the terms of a
60 permission notice identical to this one.
61
62 Permission is granted to copy and distribute translations of this manual
63 into another language, under the above conditions for modified versions.
64
65 @end titlepage
66 @page
67
68 @end tex
69
70 @node Top
71 @top Emacs MIME
72
73 This manual documents the libraries used to compose and display
74 @sc{mime} messages.
75
76 This is not a manual meant for users; it's a manual directed at people
77 who want to write functions and commands that manipulate @sc{mime}
78 elements.
79
80 @sc{mime} is short for @dfn{Multipurpose Internet Mail Extensions}.
81 This standard is documented in a number of RFCs; mainly RFC2045 (Format
82 of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
83 Header Extensions for Non-ASCII Text), RFC2048 (Registration
84 Procedures), RFC2049 (Conformance Criteria and Examples).  It is highly
85 recommended that anyone who intends writing @sc{mime}-compliant software
86 read at least RFC2045 and RFC2047.
87
88 @menu
89 * Interface Functions::   An abstraction over the basic functions.
90 * Basic Functions::       Utility and basic parsing functions.
91 * Decoding and Viewing::  A framework for decoding and viewing.
92 * Composing::             MML; a language for describing MIME parts.
93 * Standards::             A summary of RFCs and working documents used.
94 * Index::                 Function and variable index.
95 @end menu
96
97
98 @node Interface Functions
99 @chapter Interface Functions
100 @cindex interface functions
101 @cindex mail-parse
102
103 The @code{mail-parse} library is an abstraction over the actual
104 low-level libraries that are described in the next chapter.
105
106 Standards change, and so programs have to change to fit in the new
107 mold.  For instance, RFC2045 describes a syntax for the
108 @code{Content-Type} header that only allows ASCII characters in the
109 parameter list.  RFC2231 expands on RFC2045 syntax to provide a scheme
110 for continuation headers and non-ASCII characters.
111
112 The traditional way to deal with this is just to update the library
113 functions to parse the new syntax.  However, this is sometimes the wrong
114 thing to do.  In some instances it may be vital to be able to understand
115 both the old syntax as well as the new syntax, and if there is only one
116 library, one must choose between the old version of the library and the
117 new version of the library.
118
119 The Emacs MIME library takes a different tack.  It defines a series of
120 low-level libraries (@file{rfc2047.el}, @file{rfc2231.el} and so on)
121 that parses strictly according to the corresponding standard.  However,
122 normal programs would not use the functions provided by these libraries
123 directly, but instead use the functions provided by the
124 @code{mail-parse} library.  The functions in this library are just
125 aliases to the corresponding functions in the latest low-level
126 libraries.  Using this scheme, programs get a consistent interface they
127 can use, and library developers are free to create write code that
128 handles new standards.
129
130 The following functions are defined by this library:
131
132 @table @code
133 @item mail-header-parse-content-type
134 @findex mail-header-parse-content-type
135 Parse a @code{Content-Type} header and return a list on the following
136 format:
137
138 @lisp
139 ("type/subtype"
140  (attribute1 . value1)
141  (attribute2 . value2)
142  ...)
143 @end lisp
144
145 Here's an example:
146
147 @example
148 (mail-header-parse-content-type
149  "image/gif; name=\"b980912.gif\"")
150 @result{} ("image/gif" (name . "b980912.gif"))
151 @end example
152
153 @item mail-header-parse-content-disposition
154 @findex mail-header-parse-content-disposition
155 Parse a @code{Content-Disposition} header and return a list on the same
156 format as the function above.
157
158 @item mail-content-type-get
159 @findex mail-content-type-get
160 Takes two parameters---a list on the format above, and an attribute.
161 Returns the value of the attribute.
162
163 @example
164 (mail-content-type-get
165  '("image/gif" (name . "b980912.gif")) 'name)
166 @result{} "b980912.gif"
167 @end example
168
169 @item mail-header-remove-comments
170 @findex mail-header-remove-comments
171 Return a comment-free version of a header.
172
173 @example
174 (mail-header-remove-comments
175  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
176 @result{} "Gnus/5.070027  "
177 @end example
178
179 @item mail-header-remove-whitespace
180 @findex mail-header-remove-whitespace
181 Remove linear white space from a header.  Space inside quoted strings
182 and comments is preserved.
183
184 @example
185 (mail-header-remove-whitespace
186  "image/gif; name=\"Name with spaces\"")
187 @result{} "image/gif;name=\"Name with spaces\""
188 @end example
189
190 @item mail-header-get-comment
191 @findex mail-header-get-comment
192 Return the last comment in a header.
193
194 @example
195 (mail-header-get-comment 
196  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
197 @result{} "Finnish Landrace" 
198 @end example
199
200 @item mail-header-parse-address
201 @findex mail-header-parse-address
202 Parse an address and return a list containing the mailbox and the
203 plaintext name.
204
205 @example
206 (mail-header-parse-address
207  "Hrvoje Niksic <hniksic@@srce.hr>")
208 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
209 @end example
210
211 @item mail-header-parse-addresses
212 @findex mail-header-parse-addresses
213 Parse a string with list of addresses and return a list of elements like
214 the one described above.
215
216 @example
217 (mail-header-parse-addresses
218  "Hrvoje Niksic <hniksic@@srce.hr>, Steinar Bang <sb@@metis.no>")
219 @result{} (("hniksic@@srce.hr" . "Hrvoje Niksic")
220      ("sb@@metis.no" . "Steinar Bang"))
221 @end example
222
223 @item mail-header-parse-date
224 @findex mail-header-parse-date
225 Parse a date string and return an Emacs time structure.
226
227 @item mail-narrow-to-head
228 @findex mail-narrow-to-head
229 Narrow the buffer to the header section of the buffer.  Point is placed
230 at the beginning of the narrowed buffer.
231
232 @item mail-header-narrow-to-field
233 @findex mail-header-narrow-to-field
234 Narrow the buffer to the header under point.
235
236 @item mail-encode-encoded-word-region
237 @findex mail-encode-encoded-word-region
238 Encode the non-ASCII words in the region.  For instance,
239 @samp{Naïve} is encoded as @samp{=?iso-8859-1?q?Na=EFve?=}.
240
241 @item mail-encode-encoded-word-buffer
242 @findex mail-encode-encoded-word-buffer
243 Encode the non-ASCII words in the current buffer.  This function is
244 meant to be called narrowed to the headers of a message.
245
246 @item mail-encode-encoded-word-string
247 @findex mail-encode-encoded-word-string
248 Encode the words that need encoding in a string, and return the result.
249
250 @example
251 (mail-encode-encoded-word-string
252  "This is naïve, baby")
253 @result{} "This is =?iso-8859-1?q?na=EFve,?= baby"
254 @end example
255
256 @item mail-decode-encoded-word-region
257 @findex mail-decode-encoded-word-region
258 Decode the encoded words in the region.
259
260 @item mail-decode-encoded-word-string
261 @findex mail-decode-encoded-word-string
262 Decode the encoded words in the string and return the result.
263
264 @example
265 (mail-decode-encoded-word-string
266  "This is =?iso-8859-1?q?na=EFve,?= baby")
267 @result{} "This is naïve, baby"
268 @end example
269
270 @end table
271
272 Currently, @code{mail-parse} is an abstraction over @code{ietf-drums},
273 @code{rfc2047} and @code{rfc2231}.  These are documented in the
274 subsequent sections.
275
276
277
278 @node Basic Functions
279 @chapter Basic Functions
280
281 This chapter describes the basic, ground-level functions for parsing and
282 handling.  Covered here is parsing @code{From} lines, removing comments
283 from header lines, decoding encoded words, parsing date headers and so
284 on.  High-level functionality is dealt with in the next chapter
285 (@pxref{Decoding and Viewing}).
286
287 @menu
288 * rfc2231::      Parsing @code{Content-Type} headers.
289 * ietf-drums::   Handling mail headers defined by RFC822bis.
290 * rfc2047::      En/decoding encoded words in headers.
291 * time-date::    Functions for parsing dates and manipulating time.
292 * qp::           Quoted-Printable en/decoding.
293 * base64::       Base64 en/decoding.
294 * binhex::       Binhex decoding.
295 * uudecode::     Uuencode decoding.
296 * rfc1843::      Decoding HZ-encoded text.
297 * mailcap::      How parts are displayed is specified by the @file{.mailcap} file
298 @end menu
299
300
301 @node rfc2231
302 @section rfc2231
303
304 RFC2231 defines a syntax for the @code{Content-Type} and
305 @code{Content-Disposition} headers.  Its snappy name is @dfn{MIME
306 Parameter Value and Encoded Word Extensions: Character Sets, Languages,
307 and Continuations}.
308
309 In short, these headers look something like this:
310
311 @example
312 Content-Type: application/x-stuff;
313  title*0*=us-ascii'en'This%20is%20even%20more%20;
314  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
315  title*2="isn't it!"
316 @end example
317
318 They usually aren't this bad, though.
319
320 The following functions are defined by this library:
321
322 @table @code
323 @item rfc2231-parse-string
324 @findex rfc2231-parse-string
325 Parse a @code{Content-Type} header and return a list describing its
326 elements.
327
328 @example
329 (rfc2231-parse-string
330  "application/x-stuff; 
331  title*0*=us-ascii'en'This%20is%20even%20more%20;
332  title*1*=%2A%2A%2Afun%2A%2A%2A%20;
333  title*2=\"isn't it!\"")
334 @result{} ("application/x-stuff"
335     (title . "This is even more ***fun*** isn't it!"))
336 @end example
337
338 @item rfc2231-get-value
339 @findex rfc2231-get-value
340 Takes one of the lists on the format above and return
341 the value of the specified attribute.
342
343 @end table
344
345
346 @node ietf-drums
347 @section ietf-drums
348
349 @dfn{drums} is an IETF working group that is working on the replacement
350 for RFC822.
351
352 The functions provided by this library include:
353
354 @table @code
355 @item ietf-drums-remove-comments
356 @findex ietf-drums-remove-comments
357 Remove the comments from the argument and return the results.
358
359 @item ietf-drums-remove-whitespace
360 @findex ietf-drums-remove-whitespace
361 Remove linear white space from the string and return the results.
362 Spaces inside quoted strings and comments are left untouched.
363
364 @item ietf-drums-get-comment
365 @findex ietf-drums-get-comment
366 Return the last most comment from the string.
367
368 @item ietf-drums-parse-address
369 @findex ietf-drums-parse-address
370 Parse an address string and return a list that contains the mailbox and
371 the plain text name.
372
373 @item ietf-drums-parse-addresses
374 @findex ietf-drums-parse-addresses
375 Parse a string that contains any number of comma-separated addresses and
376 return a list that contains mailbox/plain text pairs.
377
378 @item ietf-drums-parse-date
379 @findex ietf-drums-parse-date
380 Parse a date string and return an Emacs time structure.
381
382 @item ietf-drums-narrow-to-header
383 @findex ietf-drums-narrow-to-header
384 Narrow the buffer to the header section of the current buffer.
385
386 @end table
387
388
389 @node rfc2047
390 @section rfc2047
391
392 RFC2047 (Message Header Extensions for Non-ASCII Text) specifies how
393 non-ASCII text in headers are to be encoded.  This is actually rather
394 complicated, so a number of variables are necessary to tweak what this
395 library does.
396
397 The following variables are tweakable:
398
399 @table @code
400 @item rfc2047-default-charset
401 @vindex rfc2047-default-charset
402 Characters in this charset should not be decoded by this library.
403 This defaults to @code{iso-8859-1}.
404
405 @item rfc2047-header-encoding-list
406 @vindex rfc2047-header-encoding-list
407 This is an alist of header / encoding-type pairs.  Its main purpose is
408 to prevent encoding of certain headers.
409
410 The keys can either be header regexps, or @code{t}.
411
412 The values can be either @code{nil}, in which case the header(s) in
413 question won't be encoded, or @code{mime}, which means that they will be
414 encoded.
415
416 @item rfc2047-charset-encoding-alist
417 @vindex rfc2047-charset-encoding-alist
418 RFC2047 specifies two forms of encoding---@code{Q} (a
419 Quoted-Printable-like encoding) and @code{B} (base64).  This alist
420 specifies which charset should use which encoding.
421
422 @item rfc2047-encoding-function-alist
423 @vindex rfc2047-encoding-function-alist
424 This is an alist of encoding / function pairs.  The encodings are
425 @code{Q}, @code{B} and @code{nil}.
426
427 @item rfc2047-q-encoding-alist
428 @vindex rfc2047-q-encoding-alist
429 The @code{Q} encoding isn't quite the same for all headers.  Some
430 headers allow a narrower range of characters, and that is what this
431 variable is for.  It's an alist of header regexps / allowable character
432 ranges. 
433
434 @item rfc2047-encoded-word-regexp
435 @vindex rfc2047-encoded-word-regexp
436 When decoding words, this library looks for matches to this regexp. 
437
438 @end table
439
440 Those were the variables, and these are this functions:
441
442 @table @code
443 @item rfc2047-narrow-to-field
444 @findex rfc2047-narrow-to-field
445 Narrow the buffer to the header on the current line.
446
447 @item rfc2047-encode-message-header
448 @findex rfc2047-encode-message-header
449 Should be called narrowed to the header of a message.  Encodes according
450 to @code{rfc2047-header-encoding-alist}.
451
452 @item rfc2047-encode-region
453 @findex rfc2047-encode-region
454 Encodes all encodable words in the region specified.
455
456 @item rfc2047-encode-string
457 @findex rfc2047-encode-string
458 Encode a string and return the results.
459
460 @item rfc2047-decode-region
461 @findex rfc2047-decode-region
462 Decode the encoded words in the region.
463
464 @item rfc2047-decode-string
465 @findex rfc2047-decode-string
466 Decode a string and return the results.
467
468 @end table
469
470
471 @node time-date
472 @section time-date
473
474 While not really a part of the @sc{mime} library, it is convenient to
475 document this library here.  It deals with parsing @code{Date} headers
476 and manipulating time.  (Not by using tesseracts, though, I'm sorry to
477 say.)
478
479 These functions convert between five formats: A date string, an Emacs
480 time structure, a decoded time list, a second number, and a day number.
481
482 The functions have quite self-explanatory names, so the following just
483 gives an overview of which functions are available.
484
485 @example
486 (parse-time-string "Sat Sep 12 12:21:54 1998 +0200")
487 @result{} (54 21 12 12 9 1998 6 nil 7200)
488
489 (date-to-time "Sat Sep 12 12:21:54 1998 +0200")
490 @result{} (13818 19266)
491
492 (time-to-seconds '(13818 19266))
493 @result{} 905595714.0
494
495 (seconds-to-time 905595714.0)
496 @result{} (13818 19266 0)
497
498 (time-to-day '(13818 19266))
499 @result{} 729644
500
501 (days-to-time 729644)
502 @result{} (961933 65536)
503
504 (time-since '(13818 19266))
505 @result{} (0 430)
506
507 (time-less-p '(13818 19266) '(13818 19145))
508 @result{} nil
509
510 (subtract-time '(13818 19266) '(13818 19145))
511 @result{} (0 121)
512
513 (days-between "Sat Sep 12 12:21:54 1998 +0200"
514               "Sat Sep 07 12:21:54 1998 +0200")
515 @result{} 5
516
517 (date-leap-year-p 2000)
518 @result{} t
519
520 (time-to-day-in-year '(13818 19266))
521 @result{} 255
522
523 @end example
524
525 And finally, we have @code{safe-date-to-time}, which does the same as
526 @code{date-to-time}, but returns a zero time if the date is
527 syntactically malformed.
528
529
530
531 @node qp
532 @section qp
533
534 This library deals with decoding and encoding Quoted-Printable text.
535
536 Very briefly explained, qp encoding means translating all 8-bit
537 characters (and lots of control characters) into things that look like
538 @samp{=EF}; that is, an equal sign followed by the byte encoded as a hex
539 string.
540
541 The following functions are defined by the library:
542
543 @table @code
544 @item quoted-printable-decode-region
545 @findex quoted-printable-decode-region
546 QP-decode all the encoded text in the specified region.
547
548 @item quoted-printable-decode-string
549 @findex quoted-printable-decode-string
550 Decode the QP-encoded text in a string and return the results.
551
552 @item quoted-printable-encode-region
553 @findex quoted-printable-encode-region
554 QP-encode all the encodable characters in the specified region.  The third
555 optional parameter @var{fold} specifies whether to fold long lines.
556 (Long here means 72.)
557
558 @item quoted-printable-encode-string
559 @findex quoted-printable-encode-string
560 QP-encode all the encodable characters in a string and return the
561 results.
562
563 @end table
564
565
566 @node base64
567 @section base64
568 @cindex base64
569
570 Base64 is an encoding that encodes three bytes into four characters,
571 thereby increasing the size by about 33%.  The alphabet used for
572 encoding is very resistant to mangling during transit.
573
574 The following functions are defined by this library:
575
576 @table @code
577 @item base64-encode-region
578 @findex base64-encode-region
579 base64 encode the selected region.  Return the length of the encoded
580 text.  Optional third argument @var{no-line-break} means do not break
581 long lines into shorter lines.
582
583 @item base64-encode-string
584 @findex base64-encode-string
585 base64 encode a string and return the result.
586
587 @item base64-decode-region
588 @findex base64-decode-region
589 base64 decode the selected region.  Return the length of the decoded
590 text.  If the region can't be decoded, return @code{nil} and don't
591 modify the buffer.
592
593 @item base64-decode-string
594 @findex base64-decode-string
595 base64 decode a string and return the result.  If the string can't be
596 decoded, @code{nil} is returned.
597
598 @end table
599
600
601 @node binhex
602 @section binhex
603 @cindex binhex
604 @cindex Apple
605 @cindex Macintosh
606
607 @code{binhex} is an encoding that originated in Macintosh environments.
608 The following function is supplied to deal with these:
609
610 @table @code
611 @item binhex-decode-region
612 @findex binhex-decode-region
613 Decode the encoded text in the region.  If given a third parameter, only
614 decode the @code{binhex} header and return the filename.
615
616 @end table
617
618
619 @node uudecode
620 @section uudecode
621 @cindex uuencode
622 @cindex uudecode
623
624 @code{uuencode} is probably still the most popular encoding of binaries
625 used on Usenet, although @code{base64} rules the mail world.
626
627 The following function is supplied by this package:
628
629 @table @code
630 @item uudecode-decode-region
631 @findex uudecode-decode-region
632 Decode the text in the region.
633 @end table
634
635
636 @node rfc1843
637 @section rfc1843
638 @cindex rfc1843
639 @cindex HZ
640 @cindex Chinese
641
642 RFC1843 deals with mixing Chinese and ASCII characters in messages.  In
643 essence, RFC1843 switches between ASCII and Chinese by doing this:
644
645 @example
646 This sentence is in ASCII.
647 The next sentence is in GB.~@{<:Ky2;S@{#,NpJ)l6HK!#~@}Bye.
648 @end example
649
650 Simple enough, and widely used in China.
651
652 The following functions are available to handle this encoding:
653
654 @table @code
655 @item rfc1843-decode-region
656 Decode HZ-encoded text in the region.
657
658 @item rfc1843-decode-string
659 Decode a HZ-encoded string and return the result.
660
661 @end table
662
663
664 @node mailcap
665 @section mailcap
666
667 The @file{~/.mailcap} file is parsed by most @sc{mime}-aware message
668 handlers and describes how elements are supposed to be displayed.
669 Here's an example file:
670
671 @example
672 image/*; gimp -8 %s
673 audio/wav; wavplayer %s
674 @end example
675
676 This says that all image files should be displayed with @samp{xv}, and
677 that realaudio files should be played by @samp{rvplayer}.
678
679 The @code{mailcap} library parses this file, and provides functions for
680 matching types.
681
682 @table @code
683 @item mailcap-mime-data
684 @vindex mailcap-mime-data
685 This variable is an alist of alists containing backup viewing rules.
686
687 @end table
688
689 Interface functions:
690
691 @table @code
692 @item mailcap-parse-mailcaps
693 @findex mailcap-parse-mailcaps
694 Parse the @code{~/.mailcap} file.
695
696 @item mailcap-mime-info
697 Takes a @sc{mime} type as its argument and returns the matching viewer.
698
699 @end table
700
701
702
703
704 @node Decoding and Viewing
705 @chapter Decoding and Viewing
706
707 This chapter deals with decoding and viewing @sc{mime} messages on a
708 higher level.
709
710 The main idea is to first analyze a @sc{mime} article, and then allow
711 other programs to do things based on the list of @dfn{handles} that are
712 returned as a result of this analysis.
713
714 @menu
715 * Dissection::  Analyzing a @sc{mime} message.
716 * Handles::     Handle manipulations.
717 * Display::     Displaying handles.
718 @end menu
719
720
721 @node Dissection
722 @section Dissection
723
724 The @code{mm-dissect-buffer} is the function responsible for dissecting
725 a @sc{mime} article.  If given a multipart message, it will recursively
726 descend the message, following the structure, and return a tree of
727 @sc{mime} handles that describes the structure of the message.
728
729
730 @node Handles
731 @section Handles
732
733 A @sc{mime} handle is a list that fully describes a @sc{mime}
734 component.
735
736 The following macros can be used to access elements in a handle:
737
738 @table @code
739 @item mm-handle-buffer
740 @findex mm-handle-buffer
741 Return the buffer that holds the contents of the undecoded @sc{mime}
742 part.
743
744 @item mm-handle-type
745 @findex mm-handle-type
746 Return the parsed @code{Content-Type} of the part.
747
748 @item mm-handle-encoding
749 @findex mm-handle-encoding
750 Return the @code{Content-Transfer-Encoding} of the part.
751
752 @item mm-handle-undisplayer
753 @findex mm-handle-undisplayer
754 Return the object that can be used to remove the displayed part (if it
755 has been displayed).
756
757 @item mm-handle-set-undisplayer
758 @findex mm-handle-set-undisplayer
759 Set the undisplayer object.
760
761 @item mm-handle-disposition
762 @findex mm-handle-disposition
763 Return the parsed @code{Content-Disposition} of the part.
764
765 @item mm-handle-disposition
766 @findex mm-handle-disposition
767 Return the description of the part.
768
769 @item mm-get-content-id
770 Returns the handle(s) referred to by @code{Content-ID}.
771
772 @end table
773
774
775 @node Display
776 @section Display
777
778 Functions for displaying, removing and saving.
779
780 @table @code
781 @item mm-display-part
782 @findex mm-display-part
783 Display the part.
784
785 @item mm-remove-part
786 @findex mm-remove-part
787 Remove the part (if it has been displayed).
788
789 @item mm-inlinable-p
790 @findex mm-inlinable-p
791 Say whether a @sc{mime} type can be displayed inline.
792
793 @item mm-automatic-display-p
794 @findex mm-automatic-display-p
795 Say whether a @sc{mime} type should be displayed automatically.
796
797 @item mm-destroy-part
798 @findex mm-destroy-part
799 Free all resources occupied by a part.
800
801 @item mm-save-part
802 @findex mm-save-part
803 Offer to save the part in a file.
804
805 @item mm-pipe-part
806 @findex mm-pipe-part
807 Offer to pipe the part to some process.
808
809 @item mm-interactively-view-part
810 @findex mm-interactively-view-part
811 Prompt for a mailcap method to use to view the part.
812
813 @end table
814
815
816 @node Composing
817 @chapter Composing
818 @cindex Composing
819 @cindex MIME Composing
820 @cindex MML
821 @cindex MIME Meta Language
822
823 Creating a @sc{mime} message is boring and non-trivial.  Therefore, a
824 library called @code{mml} has been defined that parses a language called 
825 MML (@sc{mime} Meta Language) and generates @sc{mime} messages.
826
827 @findex mml-generate-mime
828 The main interface function is @code{mml-generate-mime}.  It will
829 examine the contents of the current (narrowed-to) buffer and return a
830 string containing the @sc{mime} message.
831
832 @menu
833 * Simple MML Example::             An example MML document.
834 * MML Definition::                 All valid MML elements.
835 * Advanced MML Example::           Another example MML document.
836 @end menu
837
838
839 @node Simple MML Example
840 @section Simple MML Example
841
842 Here's a simple @samp{multipart/alternative}:
843
844 @example
845 <#multipart type=alternative>
846 This is a plain text part.
847 <#part type=text/enriched>
848 <center>This is a centered enriched part</center>
849 <#/multipart>
850 @end example
851
852 After running this through @code{mml-generate-mime}, we get this:
853
854 @example
855 Content-Type: multipart/alternative; boundary="=-=-="
856
857
858 --=-=-=
859
860
861 This is a plain text part.
862
863 --=-=-=
864 Content-Type: text/enriched
865
866
867 <center>This is a centered enriched part</center>
868
869 --=-=-=--
870 @end example
871
872
873 @node MML Definition
874 @section MML Definition
875
876 The MML language is very simple.  It looks a bit like an SGML
877 application, but it's not.
878
879 The main concept of MML is the @dfn{part}.  Each part can be of a
880 different type or use a different charset.  The way to delineate a part
881 is with a @samp{<#part ...>} tag.  Multipart parts can be introduced
882 with the @samp{<#multipart ...>} tag.  Parts are ended by the
883 @samp{<#/part>} or @samp{<#/multipart>} tags.  Parts started with the
884 @samp{<#part ...>} tags are also closed by the next open tag.
885
886 There's also the @samp{<#external ...>} tag.  These introduce
887 @samp{external/message-body} parts.
888
889 Each tag can contain zero or more parameters on the form
890 @samp{parameter=value}.  The values may be enclosed in quotation marks,
891 but that's not necessary unless the value contains white space.  So
892 @samp{filename=/home/user/#hello$^yes} is perfectly valid.
893
894 The following parameters have meaning in MML; parameters that have no
895 meaning are ignored.  The MML parameter names are the same as the
896 @sc{mime} parameter names; the things in the parentheses say which
897 header it will be used in.
898
899 @table @samp
900 @item type
901 The @sc{mime} type of the part (@code{Content-Type}).
902
903 @item filename
904 Use the contents of the file in the body of the part
905 (@code{Content-Disposition}).
906
907 @item charset
908 The contents of the body of the part are to be encoded in the character
909 set speficied (@code{Content-Type}).
910
911 @item name
912 Might be used to suggest a file name if the part is to be saved 
913 to a file (@code{Content-Type}).
914
915 @item disposition
916 Valid values are @samp{inline} and @samp{attachment}
917 (@code{Content-Disposition}).
918
919 @item encoding
920 Valid values are @samp{7bit}, @samp{8bit}, @samp{quoted-printable} and
921 @samp{base64} (@code{Content-Transfer-Encoding}).
922
923 @item description
924 A description of the part (@code{Content-Description}).
925
926 @item creation-date
927 RFC822 date when the part was created (@code{Content-Disposition}).
928
929 @item modification-date
930 RFC822 date when the part was modified (@code{Content-Disposition}).
931
932 @item read-date
933 RFC822 date when the part was read (@code{Content-Disposition}).
934
935 @item size
936 The size (in octets) of the part (@code{Content-Disposition}).
937
938 @end table
939
940 Parameters for @samp{application/octet-stream}:
941
942 @table @samp
943 @item type
944 Type of the part; informal---meant for human readers
945 (@code{Content-Type}).
946 @end table
947
948 Parameters for @samp{message/external-body}:
949
950 @table @samp
951 @item access-type
952 A word indicating the supported access mechanism by which the file may
953 be obtained.  Values include @samp{ftp}, @samp{anon-ftp}, @samp{tftp},
954 @samp{localfile}, and @samp{mailserver}.  (@code{Content-Type}.)
955
956 @item expiration
957 The RFC822 date after which the file may no longer be fetched.
958 (@code{Content-Type}.)
959
960 @item size
961 The size (in octets) of the file.  (@code{Content-Type}.)
962
963 @item permission
964 Valid values are @samp{read} and @samp{read-write}
965 (@code{Content-Type}).
966
967 @end table
968
969
970 @node Advanced MML Example
971 @section Advanced MML Example
972
973 Here's a complex multipart message.  It's a @samp{multipart/mixed} that
974 contains many parts, one of which is a @samp{multipart/alternative}. 
975
976 @example
977 <#multipart type=mixed>
978 <#part type=image/jpeg filename=~/rms.jpg disposition=inline>
979 <#multipart type=alternative>
980 This is a plain text part.
981 <#part type=text/enriched name=enriched.txt>
982 <center>This is a centered enriched part</center>
983 <#/multipart>
984 This is a new plain text part.
985 <#part disposition=attachment>
986 This plain text part is an attachment.
987 <#/multipart>
988 @end example
989
990 And this is the resulting @sc{mime} message:
991
992 @example
993 Content-Type: multipart/mixed; boundary="=-=-="
994
995
996 --=-=-=
997
998
999
1000 --=-=-=
1001 Content-Type: image/jpeg;
1002  filename="~/rms.jpg"
1003 Content-Disposition: inline;
1004  filename="~/rms.jpg"
1005 Content-Transfer-Encoding: base64
1006
1007 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
1008 Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA
1009 AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
1010 BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
1011 RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
1012 qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
1013 AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI
1014 AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E
1015 sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m
1016 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw
1017 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc
1018 L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw
1019 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm
1020 tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn
1021 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC
1022 pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm
1023 jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q==
1024
1025 --=-=-=
1026 Content-Type: multipart/alternative; boundary="==-=-="
1027
1028
1029 --==-=-=
1030
1031
1032 This is a plain text part.
1033
1034 --==-=-=
1035 Content-Type: text/enriched;
1036  name="enriched.txt"
1037
1038
1039 <center>This is a centered enriched part</center>
1040
1041 --==-=-=--
1042
1043 --=-=-=
1044
1045 This is a new plain text part.
1046
1047 --=-=-=
1048 Content-Disposition: attachment
1049
1050
1051 This plain text part is an attachment.
1052
1053 --=-=-=--
1054 @end example
1055
1056
1057
1058 @node Standards
1059 @chapter Standards
1060
1061 The Emacs @sc{mime} library implements handling of various elements
1062 according to a (somewhat) large number of RFCs, drafts and standards
1063 documents.  This chapter lists the relevant ones.  They can all be
1064 fetched from @samp{http://www.stud.ifi.uio.no/~larsi/notes/}.
1065
1066 @table @dfn
1067 @item RFC822
1068 @itemx STD11
1069 Standard for the Format of ARPA Internet Text Messages.
1070
1071 @item RFC1036
1072 Standard for Interchange of USENET Messages
1073
1074 @item RFC2045
1075 Format of Internet Message Bodies
1076
1077 @item RFC2046
1078 Media Types
1079
1080 @item RFC2047
1081 Message Header Extensions for Non-ASCII Text
1082
1083 @item RFC2048
1084 Registration Procedures
1085
1086 @item RFC2049
1087 Conformance Criteria and Examples
1088
1089 @item RFC2231
1090 MIME Parameter Value and Encoded Word Extensions: Character Sets,
1091 Languages, and Continuations
1092
1093 @item RFC1843
1094 HZ - A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and
1095 ASCII characters
1096
1097 @item draft-ietf-drums-msg-fmt-05.txt
1098 Draft for the successor of RFC822
1099
1100 @item RFC2112
1101 The MIME Multipart/Related Content-type
1102
1103 @item RFC1892
1104 The Multipart/Report Content Type for the Reporting of Mail System
1105 Administrative Messages
1106
1107 @item RFC2183
1108 Communicating Presentation Information in Internet Messages: The
1109 Content-Disposition Header Field
1110
1111 @end table
1112  
1113  
1114 @node Index
1115 @chapter Index
1116 @printindex cp
1117
1118 @summarycontents
1119 @contents
1120 @bye
1121
1122 @c End: