Skip to main content

src/sendr.erl

-module(sendr).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/sendr.gleam").
-export_type([field/0, attachment_field/0, body_field/0, sendr_error/1]).

-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(" Sendr - An email library for Gleam\n").

-type field() :: from | reply_to | to | cc | bcc | subject.

-type attachment_field() :: required_filename_missing |
    required_content_id_missing |
    attachment_type_not_supported.

-type body_field() :: no_body |
    {text_to_short, integer(), integer()} |
    {html_to_short, integer(), integer()}.

-type sendr_error(FCE) :: {required_field_missing, field()} |
    {field_exceeds_maximum_length, field(), integer(), integer()} |
    {too_many_entries, field()} |
    no_recipients |
    {invalid_mailbox, field(), sendr@message@mailbox:mailbox()} |
    {invalid_attachment,
        attachment_field(),
        sendr@message@attachment:attachment()} |
    {invalid_body, body_field()} |
    {backend_error, FCE}.