Mailroom v0.2.4 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
Connect to the POP3 server
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
Connect to the POP3 server
The following options are available:
ssl
- defaultfalse
, connect via SSL or notport
- default110
(995
if SSL), the port to connect totimeout
- default15_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}