[][src]Struct email_parser::email::Email

pub struct Email<'a> {
    pub body: Option<Cow<'a, str>>,
    pub from: Vec<Mailbox<'a>>,
    pub sender: Mailbox<'a>,
    pub subject: Option<Cow<'a, str>>,
    pub date: DateTime,
    pub to: Option<Vec<Address<'a>>>,
    pub cc: Option<Vec<Address<'a>>>,
    pub bcc: Option<Vec<Address<'a>>>,
    pub message_id: Option<(Cow<'a, str>, Cow<'a, str>)>,
    pub in_reply_to: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>,
    pub references: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>,
    pub reply_to: Option<Vec<Address<'a>>>,
    pub comments: Vec<Cow<'a, str>>,
    pub keywords: Vec<Vec<Cow<'a, str>>>,
    pub trace: Vec<(Option<Option<EmailAddress<'a>>>, Vec<(Vec<ReceivedToken<'a>>, DateTime)>, Vec<TraceField<'a>>)>,
    pub unknown_fields: Vec<(Cow<'a, str>, Cow<'a, str>)>,
}

A struct representing a valid RFC 5322 message.

Example

let email = Email::parse(
    b"\
    From: Mubelotix <mubelotix@mubelotix.dev>\r\n\
    Subject:Example Email\r\n\
    To: Someone <example@example.com>\r\n\
    Message-id: <6546518945@mubelotix.dev>\r\n\
    Date: 5 May 2003 18:58:34 +0000\r\n\
    \r\n\
    Hey!\r\n",
)
.unwrap();

assert_eq!(email.subject.unwrap(), "Example Email");
assert_eq!(email.sender.name.unwrap(), vec!["Mubelotix"]);
assert_eq!(email.sender.address.local_part, "mubelotix");
assert_eq!(email.sender.address.domain, "mubelotix.dev");

Fields

body: Option<Cow<'a, str>>

The ASCII text of the body.

from: Vec<Mailbox<'a>>

The list of authors of the message.
It's not the identity of the sender. See the sender field.

sender: Mailbox<'a>

The mailbox of the agent responsible for the actual transmission of the message.
Do not mix up with the from field that contains the list of authors.
When there is only one author, this field can be omitted, and its value is inferred. Otherwise, an explicit value is required.

subject: Option<Cow<'a, str>>

A short optional string identifying the topic of the message.

date: DateTime

The date and time at which the sender of the message indicated that the message was complete and ready to enter the mail delivery system. For instance, this might be the time that a user pushes the "send" or "submit" button in an application program.

to: Option<Vec<Address<'a>>>cc: Option<Vec<Address<'a>>>bcc: Option<Vec<Address<'a>>>message_id: Option<(Cow<'a, str>, Cow<'a, str>)>in_reply_to: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>references: Option<Vec<(Cow<'a, str>, Cow<'a, str>)>>reply_to: Option<Vec<Address<'a>>>comments: Vec<Cow<'a, str>>keywords: Vec<Vec<Cow<'a, str>>>trace: Vec<(Option<Option<EmailAddress<'a>>>, Vec<(Vec<ReceivedToken<'a>>, DateTime)>, Vec<TraceField<'a>>)>unknown_fields: Vec<(Cow<'a, str>, Cow<'a, str>)>

The list of unrecognized fields.
Each field is stored as a (name, value) tuple.

Implementations

impl<'a> Email<'a>[src]

pub fn parse(data: &'a [u8]) -> Result<Email<'a>, Error>[src]

Parse an email.

Trait Implementations

impl<'a> Debug for Email<'a>[src]

impl<'a> TryFrom<&'a [u8]> for Email<'a>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Email<'a>

impl<'a> Send for Email<'a>

impl<'a> Sync for Email<'a>

impl<'a> Unpin for Email<'a>

impl<'a> UnwindSafe for Email<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.