Send, receive and process emails.
alias Mailroom.POP3
{:ok, client} = POP3.connect(server, username, password, port: port, ssl: true)
client
|> POP3.list
|> Enum.each(fn(mail) ->
{:ok, message} = POP3.retrieve(client, mail)
# process message
:ok = POP3.delete(client, mail)
end)
:ok = POP3.reset(client)
:ok = POP3.close(client)
If available in Hex, the package can be installed as:
-
Add
mailroom
to your list of dependencies inmix.exs
:def deps do [{:mailroom, "~> 0.5.0"}] end
-
Ensure
mailroom
is started before your application:def application do [applications: [:mailroom]] end