Skip to main content

Module imap

Module imap 

Source
Expand description

An encrypted, logged-in IMAP session.

TLS is rustls with the ring provider, checked against the system’s certificates (Mozilla’s list when a system has none). STARTTLS is done here, by hand, before the IMAP client starts: the login never travels in clear. An account signed in with Google gives an access token instead of a password (SASL XOAUTH2, sasl.rs).

Structs§

Server
Where to connect, and as whom.

Constants§

COMMAND
CONNECT 🔒

Functions§

connect 🔒
Connects and encrypts, up to the server’s greeting.
login_error 🔒
A refused login; “application-specific password required” (Gmail) gets its own sentence, since the usual password will never work there. So does any password Google’s server refuses: it takes app passwords only.
network 🔒
open
Connects, encrypts and logs in: with the password, or, for an account signed in with OAuth, with an access token (the password is then unused).
read_line 🔒
server
Any other IMAP error.
sign_in_with_tokens 🔒
AUTHENTICATE XOAUTH2 on connections connect makes, with the tokens token gives: the one kept first; refused, a fresh one, once (the one kept may have ended early: a password changed, the access withdrawn); refused again, the access must be given again.
starttls 🔒
Upgrades a plain connection before anything else is said (RFC 9051 §6.2.1): the greeting, STARTTLS, its OK. Read a byte at a time, so nothing meant for TLS is swallowed.
tls_config 🔒
tls_error 🔒
A certificate problem is told apart from a network one: it may be an attack.
within
Waits at most limit; a server that does not answer is a network problem.

Type Aliases§

Imap