View Source Mailroom.IMAP (Mailroom v0.5.0)

Handles communication with a IMAP server.

Example:

{:ok, client} = Mailroom.IMAP.connect("imap.server", "username", "password")
client
|> Mailroom.IMAP.list
|> Enum.each(fn(mail) ->
  message =
    client
    |> Mailroom.IMAP.retrieve(mail)
    |> Enum.join("\n")
  # … process message
  Mailroom.IMAP.delete(client, mail)
end)
Mailroom.IMAP.reset(client)
Mailroom.IMAP.close(client)

Summary

Functions

Link to this function

add_flags(pid, number_or_range, flags, opts \\ [])

View Source

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

connect(server, username, password, options \\ [])

View Source

Connect to the IMAP server

The following options are available:

  • ssl - default false, connect via SSL or not
  • port - default 110 (995 if SSL), the port to connect to
  • timeout - default 15_000, the timeout for connection and communication

Examples:

Mailroom.IMAP.connect("imap.server", "me", "secret", ssl: true)
{:ok, pid}
Link to this function

copy(pid, sequence, mailbox_name)

View Source
Link to this function

each(pid, items_list \\ [:envelope], func)

View Source
Link to this function

examine(pid, mailbox_name)

View Source
Link to this function

fetch(pid, number_or_range, items_list, func \\ nil, opts \\ [])

View Source

Fetches the items for the specified message or range of messages

Examples:

> IMAP.fetch(client, 1, [:uid])
#…
> IMAP.fetch(client, 1..3, [:fast, :uid])
#…

Options

  • :timeout - (integer) number of milliseconds before terminating the idle command if no update has been received. Defaults to 1_500_00 (25 minutes)
Link to this function

idle(pid, callback_pid, callback_message, opts \\ [])

View Source

Callback implementation for GenServer.init/1.

Link to this function

list(pid, reference \\ "", mailbox_name \\ "*")

View Source
Link to this function

remove_flags(pid, number_or_range, flags, opts \\ [])

View Source
Link to this function

search(pid, query, items_list \\ nil, func \\ nil)

View Source
Link to this function

select(pid, mailbox_name)

View Source
Link to this function

set_flags(pid, number_or_range, flags, opts \\ [])

View Source
Link to this function

status(pid, mailbox_name, items)

View Source
Link to this function

uid_fetch(pid, number_or_range, items_list, opts \\ [])

View Source