| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Creating a MIME message is boring and non-trivial. Therefore, a
library called mml has been defined that parses a language called
MML (MIME Meta Language) and generates MIME messages.
The main interface function is mml-generate-mime. It will
examine the contents of the current (narrowed-to) buffer and return a
string containing the MIME message.
4.1 Simple MML Example An example MML document. 4.2 MML Definition All valid MML elements. 4.3 Advanced MML Example Another example MML document. 4.4 Charset Translation How charsets are mapped from MULE to MIME. 4.5 Conversion Going from MIME to MML and vice versa.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here's a simple `multipart/alternative':
<#multipart type=alternative> This is a plain text part. <#part type=text/enriched> <center>This is a centered enriched part</center> <#/multipart> |
After running this through mml-generate-mime, we get this:
Content-Type: multipart/alternative; boundary="=-=-=" --=-=-= This is a plain text part. --=-=-= Content-Type: text/enriched <center>This is a centered enriched part</center> --=-=-=-- |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The MML language is very simple. It looks a bit like an SGML application, but it's not.
The main concept of MML is the part. Each part can be of a different type or use a different charset. The way to delineate a part is with a `<#part ...>' tag. Multipart parts can be introduced with the `<#multipart ...>' tag. Parts are ended by the `<#/part>' or `<#/multipart>' tags. Parts started with the `<#part ...>' tags are also closed by the next open tag.
There's also the `<#external ...>' tag. These introduce `external/message-body' parts.
Each tag can contain zero or more parameters on the form `parameter=value'. The values may be enclosed in quotation marks, but that's not necessary unless the value contains white space. So `filename=/home/user/#hello$^yes' is perfectly valid.
The following parameters have meaning in MML; parameters that have no meaning are ignored. The MML parameter names are the same as the MIME parameter names; the things in the parentheses say which header it will be used in.
Content-Type).
Content-Disposition).
Content-Type).
Content-Type).
Content-Disposition).
Content-Transfer-Encoding).
Content-Description).
Content-Disposition).
Content-Disposition).
Content-Disposition).
Content-Disposition).
Parameters for `application/octet-stream':
Content-Type).
Parameters for `message/external-body':
Content-Type.)
Content-Type.)
Content-Type.)
Content-Type).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here's a complex multipart message. It's a `multipart/mixed' that contains many parts, one of which is a `multipart/alternative'.
<#multipart type=mixed> <#part type=image/jpeg filename=~/rms.jpg disposition=inline> <#multipart type=alternative> This is a plain text part. <#part type=text/enriched name=enriched.txt> <center>This is a centered enriched part</center> <#/multipart> This is a new plain text part. <#part disposition=attachment> This plain text part is an attachment. <#/multipart> |
And this is the resulting MIME message:
Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= --=-=-= Content-Type: image/jpeg; filename="~/rms.jpg" Content-Disposition: inline; filename="~/rms.jpg" Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAwADABAREA/8QAHwAA AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB AAA/AO/rifFHjldNuGsrDa0qcSSHkA+gHrXKw+LtWLrMb+RgTyhbr+HSug07xNqV9fQtZrNI AyiaE/NuBPOOOP0rvRNE880KOC8TbXXGCv1FPqjrF4LDR7u5L7SkTFT/ALWOP1xXgTuXfc7E sx6nua6rwp4IvvEM8chCxWxOdzn7wz6V9AaB4S07w9p5itow0rDLSY5Pt9K43xO66P4xs71m 2QXiGCbA4yOVJ9+1aYORkdK434lyNH4ahCnG66VT9Nj15JFbPdX0MS43M4VQf5/yr2vSpLnw 5ZW8dlCZ8KFXjOPX0/mK6rSPEGt3Angu44fNEReHYNvIH3TzXDeKNO8RX+kSX2ouZkicTIOc L+g7E810ulFjpVtv3bwgB3HJyK5L4quY/C9sVxk3ij/xx6850u7t1mtp/wDlpEw3An3Jr3Dw 34gsbWza4nBlhC5LDsaW6+IFgupQyCF3iHH7gA7c9R9ay7zx6t7aX9jHC4smhfBkGCvHGfrm tLQ7hbnRrV1GPkAP1x1/Hr+Ncr8Vzjwrbf8AX6v/AKA9eQRyYlQk8Yx9K6XTNbkgia2ciSIn 7p5Ga9Atte0LTLKO6it4i7dVRFJDcZ4PvXN+JvEMF9bILVGXJLSZ4zkjivRPDaeX4b08HOTC pOffmua+KkbS+GLVUGT9tT/0B68eeIpIFYjB70+OOVXyoOM9+M1eaWeCLzHPyHGO/NVWvJJm jQ8KGH1NfQWhXSXmh2c8eArRLwO3HSv/2Q== --=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= This is a plain text part. --==-=-= Content-Type: text/enriched; name="enriched.txt" <center>This is a centered enriched part</center> --==-=-=-- --=-=-= This is a new plain text part. --=-=-= Content-Disposition: attachment This plain text part is an attachment. --=-=-=-- |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
During translation from MML to MIME, for each MIME part which has been composed inside Emacs, an appropriate charset has to be chosen.
If you are running a non-MULE Emacs, this process is simple: If the
part contains any non-ASCII (8-bit) characters, the MIME charset
given by mail-parse-charset (a symbol) is used. (Never set this
variable directly, though. If you want to change the default charset,
please consult the documentation of the package which you use to process
MIME messages.
See section `Various Message Variables' in Message Manual, for example.)
If there are only ASCII characters, the MIME charset US-ASCII is
used, of course.
Things are slightly more complicated when running Emacs with MULE
support. In this case, a list of the MULE charsets used in the
part is obtained, and the MULE charsets are translated to MIME
charsets by consulting the variable mm-mime-mule-charset-alist.
If this results in a single MIME charset, this is used to encode
the part. But if the resulting list of MIME charsets contains more
than one element, two things can happen: If it is possible to encode the
part via UTF-8, this charset is used. (For this, Emacs must support
the utf-8 coding system, and the part must consist entirely of
characters which have Unicode counterparts.) If UTF-8 is not available
for some reason, the part is split into several ones, so that each one
can be encoded with a single MIME charset. The part can only be
split at line boundaries, though--if more than one MIME charset is
required to encode a single line, it is not possible to encode the part.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A (multipart) MIME message can be converted to MML with the
mime-to-mml function. It works on the message in the current
buffer, and substitutes MML markup for MIME boundaries.
Non-textual parts do not have their contents in the buffer, but instead
have the contents in separate buffers that are referred to from the MML
tags.
An MML message can be converted back to MIME by the
mml-to-mime function.
These functions are in certain senses "lossy"---you will not get back an identical message if you run MIME-TO-MML and then MML-TO-MIME. Not only will trivial things like the order of the headers differ, but the contents of the headers may also be different. For instance, the original message may use base64 encoding on text, while MML-TO-MIME may decide to use quoted-printable encoding, and so on.
In essence, however, these two functions should be the inverse of each other. The resulting contents of the message should remain equivalent, if not identical.
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |