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

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!"}}

Summary

Functions

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

Parses a RFC2822 timestamp to a DateTime with timezone

Functions

Link to this function

parse_recipient_value(value)

View Source
@spec 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

Parses a RFC2822 timestamp to a DateTime with timezone

RFC2822 3.3 - Date and Time Specification