Changeset View
Changeset View
Standalone View
Standalone View
README.md
Show All 12 Lines | The following is equally true, however: | ||||
CONTRIBUTIONS WELCOME. USAGE WELCOME. | CONTRIBUTIONS WELCOME. USAGE WELCOME. | ||||
Usage | Usage | ||||
===== | ===== | ||||
To use eimap from your imap application add the following line to your rebar | To use eimap from your imap application add the following line to your rebar | ||||
config: | config: | ||||
{ eimap, "*", {git, "git://git.kolab.org/diffusion/EI/eimap.git" } | { eimap, "*", {git, "git://git.kolab.org/diffusion/EI/eimap.git" } } | ||||
There is no need to start the eimap application as it does not have any process | There is no need to start the eimap application as it does not have any process | ||||
or startup routines related to its usage. eimap does rely on lager being avilable, | or startup routines related to its usage. eimap does rely on lager being avilable, | ||||
however. | however. | ||||
eimap Module | eimap Module | ||||
============ | ============ | ||||
The eimap erlang module is the home of the primary API for the eimap library. It | The eimap erlang module is the home of the primary API for the eimap library. It | ||||
is a gen_fsm and should be started as a process in the normal Erlang/OTP manner for | is a gen_fsm and should be started as a process in the normal Erlang/OTP manner for | ||||
use. | use. | ||||
An eimap instance represents a single IMAP connection to a single IMAP server | An eimap instance represents a single IMAP connection to a single IMAP server | ||||
and is stateful: commands that are started may change the selected folder, for | and is stateful: commands that are started may change the selected folder, for | ||||
instance, and commands that are sent may be put into a command queue for subsequent | instance, and commands that are sent may be put into a command queue for subsequent | ||||
execution depeding on the current state of the connection. | execution depeding on the current state of the connection. | ||||
Once started, an eimap process may be directed to connect to an imap server | Once started, an eimap process may be directed to connect to an imap server | ||||
and then start with functions such as fetching path tokens: | and then start with functions such as fetching path tokens: | ||||
ImapServerArgs = #eimap_server_config{ host = "acme.com" }, | ImapServerArgs = [ { host, "imap.acme.com" }, { port, 143 }, { tls, starttls } ] | ||||
{ ok, Imap } = eimap:start_link(ImapServerArgs), | { ok, Imap } = eimap:start_link(ImapServerArgs), | ||||
eimap_imap:starttls(), | eimap_imap:starttls(), | ||||
eimap_imap:login(Imap, self(), undefined, "username", "password"), | eimap_imap:login(Imap, self(), undefined, "username", "password"), | ||||
eimap_imap:connect(Imap), | eimap_imap:connect(Imap), | ||||
eimap_imap:get_path_tokens(Imap, self(), get_path_tokens) | eimap_imap:get_path_tokens(Imap, self(), get_path_tokens) | ||||
The eimap_server_config record is defined in eimap.hrl and allows one to set | The Imap server args is a simple proplist which allows one to set | ||||
host, port and TLS settings. For TLS, the following values are supported: | host, port and TLS settings. For TLS, the following values are supported: | ||||
* true: start a TLS session when opening the socket ("implicit TLS") | * true: start a TLS session when opening the socket ("implicit TLS") | ||||
* starttls: start TLS via the STARTTLS IMAP command auomagically | * starttls: start TLS via the STARTTLS IMAP command auomagically | ||||
* false: just open a regular connection; this is what you usually want, and | * false: just open a regular connection; this is what you usually want, and | ||||
the client will call eimap:starttls/3 when it wishes to switch to | the client will call eimap:starttls/3 when it wishes to switch to | ||||
an encrypted connection | an encrypted connection | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |