callback() = fun(({exit, any()} | smtp_session_error() | {ok, binary()}) -> any())
email() = {From::email_address(), To::[email_address(), ...], Body::string() | binary() | fun(() -> string() | binary())}
email_address() = string() | binary()
failure() = {temporary_failure, temporary_failure_reason()} | {permanent_failure, permanent_failure_reason()} | {missing_requirement, auth | tls} | {unexpected_response, [binary()]} | {network_failure, {error, timeout | inet:posix()}}
host_failure() = {temporary_failure, smtp_host(), temporary_failure_reason()} | {permanent_failure, smtp_host(), permanent_failure_reason()} | {missing_requirement, smtp_host(), auth | tls} | {unexpected_response, smtp_host(), [binary()]} | {network_failure, smtp_host(), {error, timeout | inet:posix()}}
options() = [{ssl, boolean()} | {tls, always | never | if_available} | {tls_options, list()} | {sockopts, [gen_tcp:connect_option()]} | {port, inet:port_number()} | {timeout, timeout()} | {relay, inet:ip_address() | inet:hostname()} | {no_mx_lookups, boolean()} | {auth, always | never | if_available} | {hostname, string()} | {retries, non_neg_integer()} | {username, string()} | {password, string()} | {trace_fun, fun((Fmt::string(), Args::[any()]) -> any())}]
permanent_failure_reason() = binary() | auth_failed | ssl_not_started
abstract datatype: smtp_client_socket()
smtp_host() = inet:hostname()
smtp_session_error() = {error, no_more_hosts | send, {permanent_failure, smtp_host(), permanent_failure_reason()}} | {error, retries_exceeded | send, host_failure()}
temporary_failure_reason() = binary() | tls_failed
validate_options_error() = no_relay | invalid_port | no_credentials
close/1 | Close an open smtp client socket opened with open/1. |
deliver/2 | Deliver an email on an open smtp client socket. |
open/1 | Open a SMTP client socket with the provided options Once the socket has been opened, you can use it with deliver/2. |
send/2 | Send an email in a non-blocking fashion via a spawned_linked process. |
send/3 | Send an email nonblocking and invoke a callback with the result of the send. |
send_blocking/2 | Send an email and block waiting for the reply. |
close(Socket::smtp_client_socket()) -> ok
Close an open smtp client socket opened with open/1.
deliver(Socket::smtp_client_socket(), Email::email()) -> {ok, Receipt::binary()} | {error, failure()}
Deliver an email on an open smtp client socket.
For use with a socket opened with open/1. The socket can be reused as long as the previous call to deliver/2 returned {ok, Receipt}
.
open(Options::options()) -> {ok, SocketDescriptor::smtp_client_socket()} | smtp_session_error() | {error, bad_option, validate_options_error()}
Open a SMTP client socket with the provided options Once the socket has been opened, you can use it with deliver/2.
send(Email::email(), Options::options()) -> {ok, pid()} | {error, validate_options_error()}
Send an email in a non-blocking fashion via a spawned_linked process. The process will exit abnormally on a send failure.
send(Email::email(), Options::options(), Callback::callback() | undefined) -> {ok, pid()} | {error, validate_options_error()}
Send an email nonblocking and invoke a callback with the result of the send.
The callback will receive either {ok, Receipt}
where Receipt is the SMTP server's receipt
identifier, {error, Type, Message}
or {exit, ExitReason}
, as the single argument.
send_blocking(Email::email(), Options::options()) -> binary() | smtp_session_error() | {error, validate_options_error()}
Send an email and block waiting for the reply. Returns either a binary that contains
the SMTP server's receipt or {error, Type, Message}
or {error, Reason}
.
Generated by EDoc