Skip to content

Commit

Permalink
bugfix: when 8BITMIME extension is enabled, BODY could be "7bit" (#283)
Browse files Browse the repository at this point in the history
see rfc6152#section-2
  • Loading branch information
seriyps authored Sep 22, 2021
1 parent d012840 commit 5bd741d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/gen_smtp_server_session.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
data = <<>> :: binary(),
expectedsize = 0 :: pos_integer() | 0,
auth = {<<>>, <<>>} :: {binary(), binary()}, % {"username", "password"}
flags = [] :: [smtputf8 | '8bitmime']
flags = [] :: [smtputf8 | '8bitmime' | '7bit']
}
).

Expand Down Expand Up @@ -530,8 +530,10 @@ handle_request({<<"MAIL">>, Args},
end;
(<<"BODY=", BodyType/binary>>, #state{envelope = #envelope{flags = Flags} = Envelope} = InnerState) ->
case has_extension(Extensions, "8BITMIME") of
{true, _} when BodyType == <<"8BITMIME">> ->
InnerState#state{envelope = Envelope#envelope{flags = ['8bitmime' | Flags]}};
{true, _} ->
Flag = maps:get(BodyType, #{<<"8BITMIME">> => '8bitmime',
<<"7BIT">> => '7bit'}),
InnerState#state{envelope = Envelope#envelope{flags = [Flag | Flags]}};
false ->
{error, "555 Unsupported option BODY\r\n"}
end;
Expand Down

0 comments on commit 5bd741d

Please sign in to comment.