module MrMime_content:sig
..end
This goal of this module is about the MIME header specification. So you can find somes mechanisms:
MrMime_mimeVersion.version
header field, which uses a version number
to declare a message to be conformant with MIME and allows mail processing
agents to distinguish between such messages and those generated by older or
non-conformant software, which are presumed to lack such a field.MrMime_contentType.content
header field, generalized from
RFC1049, which can be used to
specify the media type and subtype of data in the body of a message and to
fully specify the native representation (canonical form) of such data.MrMime_contentEncoding.mechanism
header field, which can be used to
specify both the encoding transformation that was applied to the body and
the domain of the result. Encoding transformations other than the identity
transformation are usually applied to data in order to allow it to pass
through mail transport mechanims which may have data or character set
limitations."Content-ID"
and "Content-Description"
header fields.
Several of the mechanisms described in this set of documents may seem
somewhat strange or even baroque at first reading. It is important to note
that compatibility with existing standards AND robustness across existing
practice were two of the highest priorities of the working group that
developed this set of documents. In particular, compatibility was always
favored over elegance.
See also RFC2045 § 1
module Map: module type of Map.Make(String)
type key = string
.
typeraw =
Rfc2047.raw
=
| |
QuotedPrintable of |
| |
Base64 of |
"=?"
, ends with
"?="
, and has two "?"
s in between. It specifies a character set and an
encoding method, and also includes the original text encoded as graphic
ASCII characters, according to the rules for that encoding method.
MrMime recognizes encoded-words when they appear in certain protions of the message header. Instead of displaying the encoded-word "as is", it will reverse the encoding and display the original text.
NOTE: the client need to translate the original text into the designated
character set (like utf-8
) - this feature is in TODO.
See also RFC2047
typeunstructured =
[ `CR of int
| `CRLF
| `Encoded of string * raw
| `LF of int
| `Text of string
| `WSP ] list
MrMime keeps somes informations:
`Text s
is just a string
`CR n
when MrMime decodes only somes "\r"
s characters (withtout "\n"
afterwards)`LF n
when MrMime decodes only somes "\n"
s characters`CRLF
when MrMime decodes a folding whitespace without whitespace
(like "\r\n"
)`WSP
when MrMime decodes a whitespace (like " "
or "\t"
)`Encoded (character_set, raw)
when MrMime decodes an encoded-word
(see MrMime_content.raw
)typefield =
[ `Content of string * Rfc5322.unstructured
| `ContentDescription of Rfc5322.unstructured
| `ContentEncoding of Rfc2045.mechanism
| `ContentID of Rfc822.msg_id
| `ContentType of Rfc2045.content
| `MimeVersion of Rfc2045.version
| `Skip of string ]
MrMime_header.field
, MrMime can skip somes lines with the `Skip
constructor. That means MrMime can't use any rule from
RFC2045 for this line and
keep the data without any processing.
Another point and ever as MrMime_header.field
, if MrMime recognizes a
header field decribed by
RFC2045 but it can't apply
the formal definition, it returns `Unsafe
with the MrMime_content.unstructured
value -
afterwards, the client can do a weird process.
type
t = {
|
ty : |
(* |
The
"Content-Type" field. | *) |
|
encoding : |
(* |
The
"Content-Transfer-Encoding" field. | *) |
|
version : |
(* |
The
"MIME-Version" field. | *) |
|
id : |
(* |
The
"Content-ID" field. In constructing a high-level user-agent, it
may be desirable to allow one body to make reference to another.
Accordingly, bodies may be labelled using the "Content-ID" header
field, which is syntactically identical to the "Message-ID" header
field.
MrMime does not process the
The
It is also worth noting that the
Each part of a | *) |
|
description : |
(* |
The
"Content-Description" field. The ability to associate some
descriptive information with a given body is often desirable. For
example, it may be useful to mark an "image" body as "a picture of the
SpaceShuttle Endeavoir.". Such text may be placed in the
"Content-Description" header field. This hader is always optional.See also RFC2045 § 8 | *) |
|
content : |
(* |
Future documents may elect to define additional MIME header fields for
various purposes. Any new header field that further describes the
content of a message should begin with the string
"Content-" to allow
such fields which appear in a message header to be distinguished from
ordinary RFC822 message header
fields.
MrMime considers all | *) |
|
unsafe : |
(* |
As explained for the
`Unsafe MrMime_content.field , when MrMime can't apply the
formal definition of a field described by the
RFC2045, it considers
the field as an MrMime_content.unstructured value to let the client to do a weird
processing. | *) |
|
skip : |
(* |
As explained for the
`Skip MrMime_content.field , when MrMime can't apply any rule
for a line, it stores this line in the skip field. MrMime keeps the
order of the appearance inside the email.
Generally, this field is empty. | *) |
"Content-*"
fields.val pp_raw : Format.formatter -> Rfc2047.raw -> unit
val pp_unstructured : Format.formatter -> unstructured -> unit
val pp_field : Format.formatter -> field -> unit
val pp : Format.formatter -> t -> unit
val default : t
MrMime_contentType.default
,
MrMime_contentEncoding.default
and MrMime_mimeVersion.default
, we have
a default value of a content header.module Encoder:sig
..end
module Decoder:sig
..end