# `Letterbox.Address`
[🔗](https://github.com/hattoriai/letterbox/blob/v0.1.0-rc.0/lib/letterbox/address.ex#L1)

An email address and the name that came with it.

    Letterbox.Address.parse_list(~s("Martínez, José" <jose+photos@Example.com>, ana@example.com))
    #=> [%Letterbox.Address{name: "Martínez, José", address: "jose+photos@example.com"},
    #    %Letterbox.Address{name: nil, address: "ana@example.com"}]

The domain is in lowercase; the local part stays as it came (RFC 5321
lets a server tell `Ana` from `ana`, though few do: `local/1` and
`matches?/2` compare it in lowercase). A sub-address, the part after
`+` (`jose+photos@`), is `tag/1`.

Lists are read as mail clients write them: names quoted or not, with
encoded words (`=?utf-8?Q?Jos=C3=A9?=`), comments (`ana@example.com
(Ana)`, a name when there is no other), groups (`Team: a@x, b@x;`,
`undisclosed-recipients:;`), and commas inside quotes.

# `t`

```elixir
@type t() :: %Letterbox.Address{address: String.t(), name: String.t() | nil}
```

# `base`

```elixir
@spec base(t()) :: String.t()
```

The address without its sub-address, in lowercase: `photos@in.example.com`.

# `domain`

```elixir
@spec domain(t()) :: String.t()
```

The domain, after the `@`.

# `local`

```elixir
@spec local(t()) :: String.t()
```

The local part, before the `@`, in lowercase.

# `matches?`

```elixir
@spec matches?(t(), t() | String.t()) :: boolean()
```

Whether the address is `other` (an address, as a string or a struct),
in lowercase, and with or without a sub-address when `other` has none.

# `parse`

```elixir
@spec parse(String.t() | nil) :: t() | nil
```

The first address of a header's value, or nil.

# `parse_list`

```elixir
@spec parse_list(String.t() | nil) :: [t()]
```

The addresses of a header's value (`From`, `To`, `Cc`, …), in their order.

# `tag`

```elixir
@spec tag(t()) :: String.t() | nil
```

The sub-address: what follows the first `+` of the local part
(`photos+abc123@` gives `"abc123"`), or nil.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
