Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow sender to immediately hangup after QUIT message #344

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
otp: ["24"] # https://www.erlang.org/downloads
otp: ["25"] # https://www.erlang.org/downloads
rebar3: ["3.18.0"] # https://www.rebar3.org

steps:
Expand Down
5 changes: 4 additions & 1 deletion src/gen_smtp_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,10 @@ read_possible_multiline_reply(Socket) ->
Code = binstr:substr(Packet, 1, 3),
read_multiline_reply(Socket, Code, [Packet]);
<<" ">> ->
{ok, Packet}
{ok, Packet};
_ ->
quit(Socket),
throw({unexpected_response, Packet})
end;
Error ->
throw({network_failure, Error})
Expand Down
10 changes: 9 additions & 1 deletion src/gen_smtp_server_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ handle_request({<<"NOOP">>, _Any}, State) ->
send(State, "250 Ok\r\n"),
{ok, State};
handle_request({<<"QUIT">>, _Any}, State) ->
send(State, "221 Bye\r\n"),
try_send(State, "221 Bye\r\n"),
{stop, normal, State};
handle_request(
{<<"VRFY">>, Address},
Expand Down Expand Up @@ -1358,6 +1358,14 @@ check_bare_crlf(Binary, _Prev, Op, Offset) ->
end
end.

try_send(#state{transport = Transport, socket = Sock} = St, Data) ->
case Transport:send(Sock, Data) of
ok ->
ok;
{error, _Err} ->
ok
end.

send(#state{transport = Transport, socket = Sock} = St, Data) ->
case Transport:send(Sock, Data) of
ok ->
Expand Down
Loading