mailio_pop3 (mailio v0.2.0)
POP3 client (RFC 1939, with CAPA, UIDL, TOP, STLS and the XOAUTH2 SASL mechanism).
This is the protocol only: connect, authenticate, list, identify, fetch headers or the whole message. It never sends DELE, so a caller cannot remove mail from the server by accident, and it keeps no index.
Message identity: UIDL when the server has it. A server may repeat one UIDL for identical copies, so unique_ids/1 gives repeated ids an ordinal suffix. Without UIDL the functions return pop3_unsupported and the caller decides on another identity (for example a hash of the headers and size).
Headers: TOP when the server has it; otherwise headers/4 falls back to RETR for messages up to max_retr bytes and refuses larger ones.
Config: #{host, port, tls => true | starttls | false, verify => verify_peer | verify_none, cacerts | cacertfile, credentials}. TLS certificates and host names are verified unless verify says otherwise.
Summary
Functions
Headers of a message: TOP when the server has it, else RETR when the message is at most max_retr bytes (default 2 MiB), cut at the blank line.
The whole message, refused when its size exceeds MaxBytes.
The headers and the first Lines lines of the body. The message is left on the server.
Unique-id listing. pop3_unsupported when the server has no UIDL.
Give repeated ids an ordinal suffix so identical copies stay distinct.
Types
Functions
-spec close(conn()) -> ok.
-spec headers(conn(), pos_integer(), non_neg_integer(), map()) -> {ok, binary()} | mailio_error:t().
Headers of a message: TOP when the server has it, else RETR when the message is at most max_retr bytes (default 2 MiB), cut at the blank line.
-spec list(conn()) -> {ok, [{pos_integer(), non_neg_integer()}]} | mailio_error:t().
-spec open(map()) -> {ok, conn()} | mailio_error:t().
-spec retr(conn(), pos_integer(), pos_integer()) -> {ok, binary()} | mailio_error:t().
The whole message, refused when its size exceeds MaxBytes.
-spec stat(conn()) -> {ok, non_neg_integer(), non_neg_integer()} | mailio_error:t().
-spec top(conn(), pos_integer(), non_neg_integer()) -> {ok, binary()} | mailio_error:t().
The headers and the first Lines lines of the body. The message is left on the server.
-spec uidl(conn()) -> {ok, [{pos_integer(), binary()}]} | mailio_error:t().
Unique-id listing. pop3_unsupported when the server has no UIDL.
-spec unique_ids([{pos_integer(), binary()}]) -> [{pos_integer(), binary()}].
Give repeated ids an ordinal suffix so identical copies stay distinct.