gen_smtp_server_session behaviour (gen_smtp v1.3.1-1)
View SourceProcess representing a SMTP session, extensible via a callback module. This module is implemented as a behaviour that the callback module should implement. To see the details of the required callback functions to provide, please see smtp_server_example.
See also: smtp_server_example.
Summary
Functions
Start a SMTP session linked to the calling process.
Types
-type error_class() ::
tcp_closed | tcp_error | ssl_closed | ssl_error | data_rejected | timeout | out_of_order |
ssl_handshake_error | send_error | setopts_error | data_receive_error.
-type options() :: [{callbackoptions, any()} | {certfile, file:name_all()} | {keyfile, file:name_all()} | {allow_bare_newlines, false | ignore | fix | strip} | {hostname, inet:hostname()} | {protocol, smtp | lmtp} | {tls_options, [tls_opt()]}].
-type tls_opt() :: ssl:tls_server_option().
Callbacks
-callback handle_DATA(From :: binary(), To :: [binary(), ...], Data :: binary(), State :: state()) -> {ok | error, protocol_message(), state()} | {multiple, [{ok | error, protocol_message()}], state()}.
-callback handle_error(error_class(), any(), state()) -> {ok, state()} | {stop, Reason :: any(), state()}.
-callback handle_HELO(Hostname :: binary(), State :: state()) -> {ok, pos_integer() | infinity, state()} | {ok, state()} | error_message().
-callback handle_MAIL_extension(Extension :: binary(), State :: state()) -> {ok, state()} | error.
-callback handle_RCPT_extension(Extension :: binary(), State :: state()) -> {ok, state()} | error.
-callback handle_RSET(State :: state()) -> state().
-callback handle_STARTTLS(state()) -> state().
-callback init(Hostname :: inet:hostname(), _SessionCount, Peername :: inet:ip_address(), Opts :: any()) -> {ok, Banner :: iodata(), CallbackState :: state()} | {stop, Reason :: any(), Message :: iodata()} | ignore.