net.pop #
net.pop provides a synchronous POP3 client over plain TCP. It does not provide TLS; use only connections where cleartext credentials and messages are appropriate.
Call dial(Config{server: ..., username: ..., password: ...}), then login() and stat(), list_all(), retr(number), or dele(number). Message numbers must be positive. retr returns message text with LF endings and removes POP3 dot stuffing. Transport and incomplete multiline responses return errors and close the connection. Credentials cannot contain CR, LF, or NUL. quit() sends QUIT and closes even if the server rejects it; close() aborts without committing deletions. Calling methods on a closed client returns an error. Clients are not safe for concurrent commands. TCP's standard read/write timeouts apply.
server must be a nonempty host name or IP literal; IPv6 may be bare or bracketed. port must be between 1 and 65535. stat() rejects malformed numbers and values outside V's int range.
fn dial #
fn dial(config Config) !&Client
dial connects to the server and reads its greeting. Credentials must not contain CR, LF, or NUL bytes.
struct Client #
struct Client {
Config
mut:
conn &net.TcpConn = unsafe { nil }
reader &io.BufferedReader = unsafe { nil }
opened bool
}
Client is a POP3 connection. Use dial, then login; quit (or close) ends it.
fn (Client) login #
fn (mut c Client) login() !
login authenticates with USER/PASS.
fn (Client) stat #
fn (mut c Client) stat() !(int, int)
stat returns the message count and the mailbox size in octets. Malformed numbers and values outside the int range return an error.
fn (Client) list_all #
fn (mut c Client) list_all() !string
list_all returns the server's LIST response (one number octets line per message).
fn (Client) retr #
fn (mut c Client) retr(n int) !string
retr returns the full RFC 5322 text of message n. n must be positive. The returned text uses LF line endings.
fn (Client) dele #
fn (mut c Client) dele(n int) !
dele marks message n for deletion. n must be positive.
fn (Client) quit #
fn (mut c Client) quit() !
quit ends the session cleanly (pending deletions take effect) and closes. It also closes the connection if the QUIT command fails.
fn (Client) close #
fn (mut c Client) close() !
close releases the connection without QUIT (pending deletions are lost).
struct Config #
struct Config {
pub:
server string
port int = 110
username string
password string
}
Config stores the settings used to connect a POP3 client over plain TCP. TLS is not supported.