correio/smtp

One bounded SMTP exchange per send. No connection pool or automatic retry. SMTP aborts before DATA if any recipient is refused; it never partially delivers a transaction. Accepted means every admitted envelope recipient.

Types

pub opaque type Config
pub type ConfigError {
  InvalidHost
  InvalidPort
  InvalidDeadline
  InvalidCredentials
  InvalidTrustRoots
  PlaintextCredentialsForbidden
}

Constructors

  • InvalidHost
  • InvalidPort
  • InvalidDeadline
  • InvalidCredentials
  • InvalidTrustRoots
  • PlaintextCredentialsForbidden
pub type Security {
  StartTlsRequired
  ImplicitTls
  LocalTestPlaintext
}

Constructors

  • StartTlsRequired
  • ImplicitTls
  • LocalTestPlaintext

Values

pub fn credentials(
  config: Config,
  username: String,
  password: String,
) -> Result(Config, ConfigError)
pub fn deadline(
  config: Config,
  milliseconds: Int,
) -> Result(Config, ConfigError)

Deadline includes connection, TLS, authentication and message exchange. Values range from 1 ms through 120 seconds.

pub fn implicit_tls(
  host: String,
  port: Int,
) -> Result(Config, ConfigError)
pub fn limits(config: Config, limits: message.Limits) -> Config
pub fn local_test(
  host: String,
  port: Int,
) -> Result(Config, ConfigError)

Plaintext is restricted to the literal loopback addresses and localhost. Credentials cannot be added to this configuration.

pub fn send(
  config: Config,
  message: message.Message,
) -> delivery.Outcome
pub fn sender(
  config: Config,
) -> fn(message.Message) -> delivery.Outcome
pub fn starttls(
  host: String,
  port: Int,
) -> Result(Config, ConfigError)
pub fn trust_roots(
  config: Config,
  pem: BitArray,
) -> Result(Config, ConfigError)

Replace system roots with explicit PEM certificate authorities. Peer and hostname verification remain mandatory. Certificates are parsed immediately.

✨ Search Document