mailio_smtp (mailio v0.2.0)

SMTP submission client (RFC 6409, RFC 5321).

One call submits one message. The result tells the caller exactly where a failure happened, because that decides whether a retry is safe:

  • smtp_transient (retryable): the failure came before the message body was sent (connect, TLS, authentication, envelope). Nothing was submitted.
  • smtp_rejected: the server refused the sender, every recipient or the message itself. Nothing was submitted and retrying will not help.
  • smtp_outcome_unknown: the body was sent but no final reply came. The message may have been accepted. Never resend automatically.

A success reports which recipients were accepted and which were refused.

Config: #{host, port, tls => true | starttls | false, verify => verify_peer | verify_none, cacerts | cacertfile, ehlo_name, credentials}. TLS certificates and host names are verified unless verify says otherwise. credentials is a mailio_credentials:cred().

Summary

Types

config/0

-type config() :: map().

result/0

-type result() ::
          #{accepted := [binary()],
            rejected := [#{recipient := binary(), code := integer(), reply := binary()}],
            code := integer(),
            reply := binary()}.

Functions

submit(Config, From, Rcpts, Data)

-spec submit(config(), binary(), [binary()], iodata()) -> {ok, result()} | mailio_error:t().