gen_smtp_server_session
that also serves as
documentation for the required callback API.
Behaviours: gen_smtp_server_session.
gen_smtp_server_session
that also serves as
documentation for the required callback API.
error_message() = {error, string(), #state{options = list()}}
code_change/3 | |
handle_AUTH/4 | |
handle_DATA/4 | |
handle_EHLO/3 | Handle the EHLO verb from the client. |
handle_HELO/2 | Handle the HELO verb from the client. |
handle_MAIL/2 | Handle the MAIL FROM verb. |
handle_MAIL_extension/2 | Handle an extension to the MAIL verb. |
handle_RCPT/2 | |
handle_RCPT_extension/2 | |
handle_RSET/1 | |
handle_STARTTLS/1 | |
handle_VRFY/2 | |
handle_error/3 | |
handle_info/2 | |
handle_other/3 | |
init/4 | Initialize the callback module's state for a new session. |
terminate/2 |
code_change(OldVsn::any(), State::#state{options = list()}, Extra::any()) -> {ok, #state{options = list()}}
handle_AUTH(Type::login | plain | 'cram-md5', Username::binary(), Password::binary() | {binary(), binary()}, State::#state{options = list()}) -> {ok, #state{options = list()}} | error
handle_DATA(From::binary(), To::[binary(), ...], Data::binary(), State::#state{options = list()}) -> {ok, string(), #state{options = list()}} | {error, string(), #state{options = list()}}
handle_EHLO(Hostname::binary(), Extensions::list(), State::#state{options = list()}) -> {ok, list(), #state{options = list()}} | error_message()
Handle the EHLO verb from the client. As with EHLO the hostname is provided as an argument, but in addition to that the list of ESMTP Extensions enabled in the session is passed. This list of extensions can be modified by the callback module to add/remove extensions.
The return values are{ok, Extensions, State}
where Extensions is the new list of extensions
to use for this session or {error, Message, State}
where Message is the reject message as
with handle_HELO.
handle_HELO(Hostname::binary(), State::#state{options = list()}) -> {ok, pos_integer(), #state{options = list()}} | {ok, #state{options = list()}} | error_message()
Handle the HELO verb from the client. Arguments are the Hostname sent by the client as part of the HELO and the callback State.
Return values are{ok, State}
to simply continue with a new state, {ok, MessageSize, State}
to continue with the SMTP session but to impose a maximum message size (which you can determine
, for example, by looking at the IP address passed in to the init function) and the new callback
state. You can reject the HELO by returning {error, Message, State}
and the Message will be
sent back to the client. The reject message MUST contain the SMTP status code, eg. 554.
handle_MAIL(From::binary(), State::#state{options = list()}) -> {ok, #state{options = list()}} | error_message()
Handle the MAIL FROM verb. The From argument is the email address specified by the
MAIL FROM command. Extensions to the MAIL verb are handled by the handle_MAIL_extension
function.
{ok, State}
or {error, Message, State}
as before.
handle_MAIL_extension(Extension::binary(), State::#state{options = list()}) -> {ok, #state{options = list()}} | error
Handle an extension to the MAIL verb. Return either {ok, State}
or error
to reject
the option.
handle_RCPT(To::binary(), State::#state{options = list()}) -> {ok, #state{options = list()}} | {error, string(), #state{options = list()}}
handle_RCPT_extension(Extension::binary(), State::#state{options = list()}) -> {ok, #state{options = list()}} | error
handle_RSET(State::#state{options = list()}) -> #state{options = list()}
handle_STARTTLS(State::#state{options = list()}) -> #state{options = list()}
handle_VRFY(Address::binary(), State::#state{options = list()}) -> {ok, string(), #state{options = list()}} | {error, string(), #state{options = list()}}
handle_error(Class::gen_smtp_server_session:error_class(), Details::any(), State::#state{options = list()}) -> {ok, State} | {stop, any(), State}
handle_info(Info::term(), State::term()) -> {noreply, NewState::term()} | {noreply, NewState::term(), timeout() | hibernate} | {stop, Reason::term(), NewState::term()}
handle_other(Verb::binary(), Args::binary(), State::#state{options = list()}) -> {string(), #state{options = list()}}
init(Hostname::inet:hostname(), SessionCount::non_neg_integer(), Address::inet:ip_address(), Options::list()) -> {ok, iodata(), #state{options = list()}} | {stop, any(), iodata()}
Initialize the callback module's state for a new session.
The arguments to the function are the SMTP server's hostname (for use in the SMTP banner),
The number of current sessions (eg. so you can do session limiting), the IP address of the
connecting client, and a freeform list of options for the module. The Options are extracted
from the callbackoptions
parameter passed into the gen_smtp_server_session
when it was
started.
{ok, Banner, State}
where Banner is the SMTP
banner to send to the client and State is the callback module's state. The State will be passed
to ALL subsequent calls to the callback module, so it can be used to keep track of the SMTP
session. You can also return {stop, Reason, Message}
where the session will exit with Reason
and send Message to the client.
terminate(Reason::any(), State::#state{options = list()}) -> {ok, any(), #state{options = list()}}
Generated by EDoc