View Source Yugo.Client (Yugo v0.1.0)
A persistent connection to an IMAP server.
Normally you do not call the functions in this module directly, but rather start a Client
as part
of your application's supervision tree. For example:
defmodule MyApp.Application do
use Application
@impl true
def start(_type, _args) do
children = [
{Yugo.Client,
name: :example_client,
server: "imap.example.com",
username: "me@example.com",
password: "pa55w0rd"}
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Starts an IMAP client process linked to the calling process.
Link to this section Types
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec start_link( server: String.t(), username: String.t(), password: String.t(), name: name(), port: 1..65535, tls: boolean(), mailbox: String.t(), server: String.t() ) :: GenServer.on_start()
Starts an IMAP client process linked to the calling process.
Takes arguments as a keyword list.
arguments
Arguments
:username
- Required. Username used to log in.:password
- Required. Password used to log in.:name
- Required. A name used to reference thisClient
. Can be any term.:server
- Required. The location of the IMAP server, e.g."imap.example.com"
.:port
- The port to connect to the server via. Defaults to993
.:tls
- Whether or not to connect using TLS. Defaults totrue
. If you set this tofalse
, Yugo will make the initial connection without TLS, then upgrade to a TLS connection (using STARTTLS) before logging in. Yugo will never send login credentials over an insecure connection.:mailbox
- The name of the mailbox to monitor for emails. Defaults to"INBOX"
. The default "INBOX" mailbox is defined in the IMAP standard. If your account has other mailboxes, you can pass the name of one as a string. A singleClient
can only monitor a single mailbox - to monitor multiple mailboxes, you need to start multipleClient
s.
example
Example
Normally, you do not call this function directly, but rather run it as part of your application's supervision tree.
See the top of this page for example Application
usage.