View Source Yugo (Yugo v0.1.0)
Auxiliary functions for Yugo.
Link to this section Summary
Types
A body consists of a list of "parts".
Each part has a mime type (e.g. "text/html"
) and associated data stored as a string/binary.
An email message sent to a subscribed process.
e.g. "text/html"
, "image/png"
, "text/plain"
, etc.
Link to this section Types
@type address() :: String.t()
A body consists of a list of "parts".
Each part has a mime type (e.g. "text/html"
) and associated data stored as a string/binary.
Note that an email can contain multiple bodies, which can each contain multiple parts.
@type email() :: %{ bcc: [address()], bodies: [body()], cc: [address()], date: DateTime.t(), flags: [flag()], in_reply_to: nil | String.t(), message_id: nil | String.t(), reply_to: [address()], sender: [address()], subject: nil | String.t(), to: [address()] }
An email message sent to a subscribed process.
a-note-on-bodies
A note on "bodies"
A single email can have multiple bodies. A common example is an email with an attachment: The "text" of the email would be contained in one body, and the attached file would be in the second body. A body can itself have multiple parts.
@type flag() :: :seen | :answered | :flagged | :draft | :deleted
@type mime_type() :: String.t()
e.g. "text/html"
, "image/png"
, "text/plain"
, etc.
For more, see this list of MIME types.
Link to this section Functions
@spec subscribe(Yugo.Client.name(), Yugo.Filter.t()) :: :ok
Subscribes the calling process to the Client
named by client_name
.
When you subscribe to a client, your process will be notified about new emails via a message
in the form {:email, client, message}
, where client
is the name of the client that is notifying you,
and message
is the email. See the email
type for the structure of the message
field.
You may also pass an optional Filter
as the second argument to match what
emails you want to be notified about. If you do not pass a filter, it defaults to Filter.all
,
which allows all emails to pass through.
@spec unsubscribe(Yugo.Client.name()) :: :ok
Unsubscribes the calling process from the specified Client
.
This will unsubscribe the calling process from all messages from the client,
regardless of how many separate times you subscribe
d