Mail.Parsers.RFC2822 (mail v0.2.3) View Source

RFC2822 Parser

Will attempt to parse a valid RFC2822 message back into a %Mail.Message{} data model.

Mail.Parsers.RFC2822.parse(message)
%Mail.Message{body: "Some message", headers: %{to: ["user@example.com"], from: "other@example.com", subject: "Read this!"}}

Link to this section Summary

Functions

Parses a RFC2822 timestamp to an Erlang timestamp

Retrieves the "name" and "address" parts from an email message recipient (To, CC, etc.). The following is an example of recipient value

Link to this section Functions

Parses a RFC2822 timestamp to an Erlang timestamp

RFC2822 3.3 - Date and Time Specification

Timezone information is ignored

Specs

Link to this function

parse_recipient_value(value)

View Source

Specs

parse_recipient_value(value :: String.t()) :: [
  {String.t(), String.t()} | String.t()
]

Retrieves the "name" and "address" parts from an email message recipient (To, CC, etc.). The following is an example of recipient value:

Full Name <fullname@company.tld>, another@company.tld

In this example, Full Name is the "name" part and fullname@company.tld is the "address" part. another@company.tld does not have a "name" part, only an "address" part.

The return value is a mixed list of tuples and strings, which should be interpreted in the following way:

  • When the element is just a string, it represents the "address" part only
  • When the element is a tuple, the format is {name, address}. Both "name" and "address" are strings