Yugo (Yugo v1.0.1)
View SourceAuxiliary functions for Yugo.
Summary
Types
The first field is the name associated with the address, and the second field is the address itself.
A body can be either "onepart" or "multipart".
An email message sent to a subscribed process.
e.g. "text/html"
, "image/png"
, "text/plain"
, etc.
Types
The first field is the name associated with the address, and the second field is the address itself.
e.g. {"Bart", "bart@simpsons.family"}
A body can be either "onepart" or "multipart".
A "onepart" body is a tuple in the form {mime_type, params, content}
, where mime_type
is a mime_type
,
params
is a string->string map, and content
is a binary
.
A "multipart" body consists of a list of body
s, which can themselves be either onepart or multipart.
@type email() :: %{ bcc: [address()], body: body(), cc: [address()], date: DateTime.t(), flags: [flag()], in_reply_to: nil | String.t(), message_id: nil | String.t(), reply_to: [address()], sender: [address()], from: [address()], subject: nil | String.t(), to: [address()] }
An email message sent to a subscribed process.
Difference between sender
and from
Both "sender" and "from" are fields used by IMAP to indicate the origin of the email. They are usually the same, but they can be different and they have different meanings:
from
- the author who physically wrote the email.From
is typically the address you see when viewing the message in an email client.sender
- the person who sent the email, potentially different thanfrom
if someone else sent the email on behalf of the author.
@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.
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