lumenmail/types
Core types for the lumenmail library. This module defines all the fundamental types used throughout the library.
Types
Represents an email address with an optional display name.
pub type Address {
Address(name: option.Option(String), email: String)
}
Constructors
-
Address(name: option.Option(String), email: String)
SMTP authentication mechanisms.
pub type AuthMechanism {
AuthPlain
AuthLogin
AuthCramMd5
AuthXOAuth2
}
Constructors
-
AuthPlainPLAIN authentication (base64 encoded)
-
AuthLoginLOGIN authentication
-
AuthCramMd5CRAM-MD5 authentication (challenge-response)
-
AuthXOAuth2XOAUTH2 for OAuth2 providers like Gmail
Connection state.
pub type ConnectionState {
Disconnected
Connected
Authenticated
}
Constructors
-
Disconnected -
Connected -
Authenticated
Authentication credentials for SMTP.
pub type Credentials {
Plain(username: String, password: String)
OAuth2(username: String, token: String)
}
Constructors
-
Plain(username: String, password: String)Username and password authentication
-
OAuth2(username: String, token: String)OAuth2 token authentication (for services like Gmail)
Server capabilities discovered via EHLO.
pub type ServerCapabilities {
ServerCapabilities(
starttls: Bool,
auth_mechanisms: List(AuthMechanism),
eight_bit_mime: Bool,
pipelining: Bool,
size: Int,
dsn: Bool,
extensions: List(String),
)
}
Constructors
-
ServerCapabilities( starttls: Bool, auth_mechanisms: List(AuthMechanism), eight_bit_mime: Bool, pipelining: Bool, size: Int, dsn: Bool, extensions: List(String), )Arguments
- starttls
-
Server supports STARTTLS
- auth_mechanisms
-
Supported authentication mechanisms
- eight_bit_mime
-
Server supports 8-bit MIME
- pipelining
-
Server supports pipelining
- size
-
Maximum message size (0 = unlimited)
- dsn
-
Server supports DSN (Delivery Status Notifications)
- extensions
-
Raw EHLO response lines
Errors that can occur during SMTP operations.
pub type SmtpError {
ConnectionFailed(reason: String)
TlsError(reason: String)
AuthenticationFailed(reason: String)
CommandRejected(code: Int, message: String)
InvalidAddress(address: String)
MessageRejected(reason: String)
Timeout
DnsError(reason: String)
ConnectionClosed
InvalidResponse(response: String)
IoError(reason: String)
}
Constructors
-
ConnectionFailed(reason: String)Failed to establish TCP connection
-
TlsError(reason: String)TLS handshake failed
-
AuthenticationFailed(reason: String)Authentication failed
-
CommandRejected(code: Int, message: String)SMTP command was rejected by server
-
InvalidAddress(address: String)Invalid email address format
-
MessageRejected(reason: String)Message was rejected by server
-
TimeoutConnection timeout
-
DnsError(reason: String)DNS resolution failed
-
ConnectionClosedServer closed connection unexpectedly
-
InvalidResponse(response: String)Invalid server response
-
IoError(reason: String)General IO error
SMTP response from server.
pub type SmtpResponse {
SmtpResponse(code: Int, message: String, is_multiline: Bool)
}
Constructors
-
SmtpResponse(code: Int, message: String, is_multiline: Bool)
Result type for SMTP operations.
pub type SmtpResult(a) =
Result(a, SmtpError)
Values
pub fn address(email: String) -> Address
Constructs an Address from just an email string.
pub fn address_with_name(name: String, email: String) -> Address
Constructs an Address with both name and email.
pub fn empty_capabilities() -> ServerCapabilities
Creates default/empty server capabilities.