View Source gen_smtp_server_session behaviour (gen_smtp v1.2.0)

Process 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.

Link to this section Summary

Link to this section Types

Specs

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.

Specs

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()]}].

Specs

protocol_message() :: string() | iodata().

Specs

tls_opt() :: ssl:tls_server_option().

Link to this section Callbacks

Specs

code_change(OldVsn :: any(), State :: state(), Extra :: any()) -> {ok, state()}.
Link to this callback

handle_AUTH/4

View Source (optional)

Specs

handle_AUTH(AuthType :: login | plain | 'cram-md5',
            Username :: binary(),
            Credential :: binary() | {binary(), binary()},
            State :: state()) ->
               {ok, state()} | any().

Specs

handle_DATA(From :: binary(), To :: [binary(), ...], Data :: binary(), State :: state()) ->
               {ok | error, protocol_message(), state()} |
               {multiple, [{ok | error, protocol_message()}], state()}.
the 'multiple' reply is only available for LMTP

Specs

handle_EHLO(Hostname :: binary(), Extensions :: list(), State :: state()) ->
               {ok, list(), state()} | error_message().

Specs

handle_HELO(Hostname :: binary(), State :: state()) ->
               {ok, pos_integer() | infinity, state()} | {ok, state()} | error_message().

Specs

handle_MAIL(From :: binary(), State :: state()) -> {ok, state()} | {error, string(), state()}.

Specs

handle_MAIL_extension(Extension :: binary(), State :: state()) -> {ok, state()} | error.

Specs

handle_RCPT(To :: binary(), State :: state()) -> {ok, state()} | {error, string(), state()}.

Specs

handle_RCPT_extension(Extension :: binary(), State :: state()) -> {ok, state()} | error.

Specs

handle_RSET(State :: state()) -> state().

Specs

handle_STARTTLS(state()) -> state().

Specs

handle_VRFY(Address :: binary(), State :: state()) ->
               {ok, string(), state()} | {error, string(), state()}.
Link to this callback

handle_error/3

View Source (optional)

Specs

handle_error(error_class(), any(), state()) -> {ok, state()} | {stop, Reason :: any(), state()}.
Link to this callback

handle_info/2

View Source (optional)

Specs

handle_info(Info :: term(), State :: state()) ->
               {noreply, NewState :: state()} |
               {noreply, NewState :: state(), timeout() | hibernate} |
               {stop, Reason :: term(), NewState :: term()}.

Specs

handle_other(Verb :: binary(), Args :: binary(), state()) -> {string() | noreply, state()}.

Specs

init(Hostname :: inet:hostname(), _SessionCount, Peername :: inet:ip_address(), Opts :: any()) ->
        {ok, Banner :: iodata(), CallbackState :: state()} |
        {stop, Reason :: any(), Message :: iodata()} |
        ignore.

Specs

terminate(Reason :: any(), state()) -> {ok, Reason :: any(), state()}.

Link to this section Functions

Link to this function

code_change(OldVsn, State, Extra)

View Source

Specs

code_change(OldVsn :: any(), State :: #state{}, Extra :: any()) -> {ok, #state{}}.
Link to this function

handle_call(Request, From, State)

View Source
Link to this function

handle_info(Message, State)

View Source

Specs

handle_info(Message :: any(), State :: #state{}) -> {noreply, #state{}} | {stop, any(), #state{}}.
Link to this function

start_link(Ref, Transport, Options)

View Source

Specs

start_link(Ref :: ranch:ref(),
           Transport :: module(),
           {Callback :: module(), Options :: options()}) ->
              {ok, pid()}.
Start a SMTP session linked to the calling process.
Link to this function

start_link(Ref, Sock, Transport, Options)

View Source
Link to this function

terminate(Reason, State)

View Source

Specs

terminate(Reason :: any(), State :: #state{}) -> ok.