Parses the scheme-specific part of a mailto URL as defined
in RFC 6068.
The recipient addresses and the header fields in the query
(subject, body and so on) are percent-decoded during
parsing. RFC 2047
encoded words are not decoded. The primary API is parse/1,
which URL.new/1 calls for any URL with the mailto scheme.
Summary
Types
Functions
Parses the path and query of a mailto URI into a t/0 struct.
Arguments
uriis aURI.t/0whose:schemeis"mailto".
Returns
{:ok, t:t/0}with the list of recipient addresses in:to(empty when the URL has no address) and the decoded header fields in:params, or{:error, {URL.Parser.ParseError, reason}}if the address list or a header field cannot be parsed.
Examples
iex> mailto = URI.parse("mailto:user@%E7%B4%8D%E8%B1%86.example.org?subject=Test&body=NATTO")
iex> URL.Mailto.parse(mailto)
{:ok,
%URL.Mailto{
to: ["user@納豆.example.org"],
params: %{"body" => "NATTO", "subject" => "Test"}
}}
iex> URL.Mailto.parse(URI.parse("mailto:?subject=Test"))
{:ok, %URL.Mailto{to: [], params: %{"subject" => "Test"}}}
iex> {:error, {URL.Parser.ParseError, _reason}} = URL.Mailto.parse(URI.parse("mailto:a@b.com?subject"))