Skip to content

Commit

Permalink
Merge pull request #97 from lazedo/patch-2
Browse files Browse the repository at this point in the history
allow noreply in handle_other
  • Loading branch information
Vagabond committed Mar 24, 2016
2 parents fb667c6 + 9f81a2d commit adb736e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/gen_smtp_server_session.erl
Expand Up @@ -91,7 +91,7 @@
-callback handle_VRFY(Address :: binary(), State :: state()) ->
{'ok', string(), state()} | {'error', string(), state()}.
-callback handle_other(Verb :: binary(), Args :: binary(), state()) ->
{string(), state()}.
{string() | 'noreply', state()}.



Expand Down Expand Up @@ -614,9 +614,14 @@ handle_request({<<"STARTTLS">>, _Args}, #state{socket = Socket} = State) ->
{ok, State};
handle_request({Verb, Args}, #state{socket = Socket, module = Module, callbackstate = OldCallbackState} = State) ->
{Message, CallbackState} = Module:handle_other(Verb, Args, OldCallbackState),
socket:send(Socket, [Message, "\r\n"]),
maybe_reply(Message, Socket),
{ok, State#state{callbackstate = CallbackState}}.

-spec(maybe_reply/2 :: (Message :: string() | 'noreply', Socket :: socket:socket()) -> 'ok' | {'error', any()}).
maybe_reply('noreply', _) -> 'ok';
maybe_reply(Message, Socket) ->
socket:send(Socket, [Message, "\r\n"]).

-spec(parse_encoded_address/1 :: (Address :: binary()) -> {binary(), binary()} | 'error').
parse_encoded_address(<<>>) ->
error; % empty
Expand Down

0 comments on commit adb736e

Please sign in to comment.