Mailroom v0.1.2 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
Link to this function
close(socket) View Source
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
- 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{}}
Link to this function
delete(socket, mail) View Source
Marks a message for deletion.
Examples:
> Mailroom.POP3.delete(socket, {1, 100})
:ok
> Mailroom.POP3.delete(socket, 1)
:ok
Link to this function
list(socket) View Source
Retrieves a list of all messages
Examples:
Mailroom.POP3.list(socket)
[{1, 100}, {2, 200}]
Link to this function
quit(socket) View Source
Sends the QUIT command to end the transaction.
Examples:
> Mailroom.POP3.reset(socket)
:ok
Link to this function
reset(socket) View Source
Resets all messages marked for deletion.
Examples:
> Mailroom.POP3.reset(socket)
:ok
Link to this function
retrieve(socket, mail) View Source
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"]
Link to this function
stat(socket) View Source
Retrieves the number of available messages and the total size in octets
Examples:
Mailroom.POP3.stat(socket)
{12, 13579}