A representation of a group address. It has a name and a list of mailboxes.
A simple wrapper around
Vec<MailAddr>. This is primarily here so we can implement the Display trait on it, and allow user code to easily convert the return value from
addrparseback into a string. However there are some additional utility functions on this wrapper as well.
A struct that represents a single header in the message. It holds slices into the raw byte array passed to parse_mail, and so the lifetime of this struct must be contained within the lifetime of the raw input. There are additional accessor functions on this struct to extract the data as Rust strings.
A simple wrapper around
Vec<String>. This is primarily here so we can implement the Display trait on it, and allow user code to easily convert the return value from
msgidparseback into a string. This also allows to add additional methods on this type in the future.
A struct to hold a more structured representation of the Content-Disposition header. This is provided mostly as a convenience since this metadata is usually needed to interpret the message body properly.
A struct to hold a more structured representation of the Content-Type header. This is provided mostly as a convenience since this metadata is usually needed to interpret the message body properly.
Struct that holds the structured representation of the message. Note that since MIME allows for nested multipart messages, a tree-like structure is necessary to represent it properly. This struct accomplishes that by holding a vector of other ParsedMail structures for the subparts.
A representation of a single mailbox. Each mailbox has a routing address
addrand an optional display name.
The possible disposition types in a Content-Disposition header. A more comprehensive list of IANA-recognized types can be found at https://www.iana.org/assignments/cont-disp/cont-disp.xhtml. This library only enumerates the types most commonly found in email messages, and provides the
Extensionvalue for holding all other types.
An abstraction over the two different kinds of top-level addresses allowed in email headers. Group addresses have a name and a list of mailboxes. Single addresses are just a mailbox. Each mailbox consists of what you would consider an email address (e.g. firstname.lastname@example.org) and optionally a display name (“Foo Bar”). Groups are represented in email headers with colons and semicolons, e.g. To: my-peeps: email@example.com, firstname.lastname@example.org;
An error type that represents the different kinds of errors that may be encountered during message parsing.
A trait that is implemented by the MailHeader slice. These functions are also available on Vec
which is returned by the parse_headers
function. It provides a map-like interface to look up header values by their
Convert an address field from an email header into a structured type. This function handles the most common formatting of to/from/cc/bcc fields found in email headers. Note that if you are attempting to parse the value of a
MailHeader, it is better (both for correctness and performance to use the
addrparse_headerfunction instead of this one. Correctness is impacted because of the way encoded words within the header are processed; using
MailHeader::get_value()will decode encoded words, which may then contain characters like commas that affect how
addrparseparses the value. This can produce incorrect results in some cases; using
addrparse_headerwill avoid this problem.
MailHeaderthat contains addresses in the value (e.g. from/to/cc/bcc) and produce a structured type representing those addresses.
Convert a date field from an email header into a UNIX epoch timestamp. This function handles the most common formatting of date fields found in email headers. It may fail to parse some of the more creative formattings.
Parse an email header into a structured type holding a list of message ids. This function can be used to parse headers containing message IDs, such as
References. This function is currently mostly trivial (splits on whitespace and strips angle-brackets) but may be enhanced in the future to strip comments (which are technically allowed by the RFCs but never really used in practice).
Helper method to parse a header value as a Content-Disposition header. The disposition defaults to “inline” if no disposition parameter is provided in the header value.
Helper method to parse a header value as a Content-Type header. Note that the returned object’s
paramsmap will contain a charset key if a charset was explicitly specified in the header; otherwise the
paramsmap will not contain a charset key. Regardless, the
charsetfield will contain a charset - either the one explicitly specified or the default of “us-ascii”.
Parse a single header from the raw data given. This function takes raw byte data, and starts parsing it, expecting there to be a MIME header key-value pair right at the beginning. It parses that header and returns it, along with the index at which the next header is expected to start. If you just want to parse a single header, you can ignore the second component of the tuple, which is the index of the next header. Error values are returned if the data could not be successfully interpreted as a MIME key-value pair.
Parses all the headers from the raw data given. This function takes raw byte data, and starts parsing it, expecting there to be zero or more MIME header key-value pair right at the beginning, followed by two consecutive newlines (i.e. a blank line). It parses those headers and returns them in a vector. The normal vector functions can be used to access the headers linearly, or the MailHeaderMap trait can be used to access them in a map-like fashion. Along with this vector, the function returns the index at which the message body is expected to start. If you just care about the headers, you can ignore the second component of the returned tuple. Error values are returned if there was some sort of parsing error.
The main mail-parsing entry point. This function takes the raw data making up the message body and returns a structured version of it, which allows easily accessing the header and body information as needed.