Mailroom v0.1.0 Mailroom.POP3 View Source

Handles communication with a POP3 server.

Example:

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

Link to this section Summary

Functions

Sends the QUIT command and closes the connection

Marks a message for deletion.

Retrieves a list of all messages

Sends the QUIT command to end the transaction.

Resets all messages marked for deletion.

Retrieves a message.

Retrieves the number of available messages and the total size in octets

Link to this section Functions

Sends the QUIT command and closes the connection

Examples:

Mailroom.POP3.close(socket)
:ok
Link to this function

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

Connect to the POP3 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.POP3.connect("pop3.myserver", "me", "secret", ssl: true)
{:ok, %Mailroom.Socket{}}

Marks a message for deletion.

Examples:

> Mailroom.POP3.delete(socket, {1, 100})
:ok
> Mailroom.POP3.delete(socket, 1)
:ok

Retrieves a list of all messages

Examples:

Mailroom.POP3.list(socket)
[{1, 100}, {2, 200}]

Sends the QUIT command to end the transaction.

Examples:

> Mailroom.POP3.reset(socket)
:ok

Resets all messages marked for deletion.

Examples:

> Mailroom.POP3.reset(socket)
:ok

Retrieves a message.

Examples:

> Mailroom.POP3.retrieve(socket, {1, 100})
["Date: Fri, 30 Sep 2016 10:48:00 +0200", "Subject: Test message", "To: user@example.com", "", "Test message"]
> Mailroom.POP3.retrieve(socket, 1)
["Date: Fri, 30 Sep 2016 10:48:00 +0200", "Subject: Test message", "To: user@example.com", "", "Test message"]

Retrieves the number of available messages and the total size in octets

Examples:

Mailroom.POP3.stat(socket)
{12, 13579}