lumenmail/network

Network module for SMTP operations. Provides TCP and SSL socket handling using Erlang’s gen_tcp and ssl modules. This is a pure Gleam implementation using @external declarations.

Types

Opaque socket type that can be either TCP or SSL socket.

pub type Socket

Options for TCP connection.

pub type TcpOption {
  Binary
  ActiveFalse
  PacketLine
  ReuseAddr
}

Constructors

  • Binary
  • ActiveFalse
  • PacketLine
  • ReuseAddr

Values

pub fn close_socket(socket: Socket, is_tls: Bool) -> Nil

Closes the socket.

pub fn read_multiline_response(
  socket: Socket,
  is_tls: Bool,
  timeout: Int,
) -> Result(types.SmtpResponse, types.SmtpError)

Reads a multi-line SMTP response (e.g., EHLO response).

pub fn read_response(
  socket: Socket,
  is_tls: Bool,
  timeout: Int,
) -> Result(types.SmtpResponse, types.SmtpError)

Reads a single-line SMTP response.

pub fn send_command(
  socket: Socket,
  is_tls: Bool,
  command: String,
  timeout: Int,
) -> Result(Nil, types.SmtpError)

Sends an SMTP command (appends CRLF).

pub fn send_data(
  socket: Socket,
  is_tls: Bool,
  data: String,
  timeout: Int,
) -> Result(Nil, types.SmtpError)

Sends raw data (for message body) with dot-stuffing.

pub fn ssl_connect(
  socket: Socket,
  host: String,
  allow_invalid_certs: Bool,
  timeout: Int,
) -> Result(Socket, types.SmtpError)

Upgrades a TCP socket to SSL/TLS.

pub fn tcp_connect(
  host: String,
  port: Int,
  timeout: Int,
) -> Result(Socket, types.SmtpError)

Establishes a TCP connection to the SMTP server.

Search Document