Packages

A Gleam library for sending emails via SMTP, inspired by the Rust mail-send crate

Current section

Files

Jump to
lumenmail src lumenmail@types.erl
Raw

src/lumenmail@types.erl

-module(lumenmail@types).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/lumenmail/types.gleam").
-export([address/1, address_with_name/2, empty_capabilities/0]).
-export_type([address/0, credentials/0, tls_mode/0, auth_mechanism/0, smtp_error/0, smtp_response/0, connection_state/0, server_capabilities/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Core types for the lumenmail library.\n"
" This module defines all the fundamental types used throughout the library.\n"
).
-type address() :: {address, gleam@option:option(binary()), binary()}.
-type credentials() :: {plain, binary(), binary()} |
{o_auth2, binary(), binary()}.
-type tls_mode() :: none | start_tls | implicit_tls.
-type auth_mechanism() :: auth_plain |
auth_login |
auth_cram_md5 |
auth_x_o_auth2.
-type smtp_error() :: {connection_failed, binary()} |
{tls_error, binary()} |
{authentication_failed, binary()} |
{command_rejected, integer(), binary()} |
{invalid_address, binary()} |
{message_rejected, binary()} |
timeout |
{dns_error, binary()} |
connection_closed |
{invalid_response, binary()} |
{io_error, binary()}.
-type smtp_response() :: {smtp_response, integer(), binary(), boolean()}.
-type connection_state() :: disconnected | connected | authenticated.
-type server_capabilities() :: {server_capabilities,
boolean(),
list(auth_mechanism()),
boolean(),
boolean(),
integer(),
boolean(),
list(binary())}.
-file("src/lumenmail/types.gleam", 12).
?DOC(" Constructs an Address from just an email string.\n").
-spec address(binary()) -> address().
address(Email) ->
{address, none, Email}.
-file("src/lumenmail/types.gleam", 17).
?DOC(" Constructs an Address with both name and email.\n").
-spec address_with_name(binary(), binary()) -> address().
address_with_name(Name, Email) ->
{address, {some, Name}, Email}.
-file("src/lumenmail/types.gleam", 114).
?DOC(" Creates default/empty server capabilities.\n").
-spec empty_capabilities() -> server_capabilities().
empty_capabilities() ->
{server_capabilities, false, [], false, false, 0, false, []}.