Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

seems like smtp_server_example is broken when called with {relay, true} #346

Open
brigadier opened this issue Jan 19, 2025 · 0 comments
Open

Comments

@brigadier
Copy link

seems like smtp_server_example is broken when called with the {relay, true} option (that is when it is doing actual job, not just printing in the console)

initialization:

application:start(ranch).
gen_smtp_server:start(smtp_server_example, [{sessionoptions, [{allow_bare_newlines, fix},
                       {callbackoptions, [{relay, true}, {parse, true}]}]}]).

Error:

** Reason for termination ==
** {{badmatch,ok},
    [{gen_smtp_server_session,handle_info,2,
                              [{file,"/home/evgeny/projects/gen_smtp/src/gen_smtp_server_session.erl"},
                               {line,296}]},
     {gen_server,try_handle_info,3,[{file,"gen_server.erl"},{line,2173}]},
     {gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,2261}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,329}]}]}

The reason is:

in the gen_smtp_server_session:

{ResponseType, Value, CallbackState} = Module:handle_DATA(
                From, To, Data, OldCallbackState
            )

in the smtp_server_example:

case proplists:get_value(relay, State#state.options, false) of
        true ->
            relay(From, To, Data)

and then relay returns ok, not 3-tuple

relay(_, [], _) ->
    ok;
relay(From, [To | Rest], Data) ->
    % relay message to email address
    [_User, Host] = string:tokens(binary_to_list(To), "@"),
    gen_smtp_client:send({From, [To], erlang:binary_to_list(Data)}, [{relay, Host}]),
    relay(From, Rest, Data).
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant