Skip to content

Commit

Permalink
Add period escape test for outgoing mail
Browse files Browse the repository at this point in the history
  • Loading branch information
evax committed Jan 30, 2014
1 parent e41d8f7 commit 1af6543
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/gen_smtp_client.erl
Expand Up @@ -774,7 +774,30 @@ session_start_test_() ->
}
end,
fun({ListenSock}) ->
{"a valid complete transaction with binary arguments shoyld succeed",
{"a valid complete transaction exercising period escaping",
fun() ->
Options = [{relay, "localhost"}, {port, 9876}, {hostname, "testing"}],
{ok, _Pid} = send({"test@foo.com", ["foo@bar.com"], ".hello world"}, Options),
{ok, X} = socket:accept(ListenSock, 1000),
socket:send(X, "220 Some banner\r\n"),
?assertMatch({ok, "EHLO testing\r\n"}, socket:recv(X, 0, 1000)),
socket:send(X, "250 hostname\r\n"),
?assertMatch({ok, "MAIL FROM: <test@foo.com>\r\n"}, socket:recv(X, 0, 1000)),
socket:send(X, "250 ok\r\n"),
?assertMatch({ok, "RCPT TO: <foo@bar.com>\r\n"}, socket:recv(X, 0, 1000)),
socket:send(X, "250 ok\r\n"),
?assertMatch({ok, "DATA\r\n"}, socket:recv(X, 0, 1000)),
socket:send(X, "354 ok\r\n"),
?assertMatch({ok, "..hello world\r\n"}, socket:recv(X, 0, 1000)),
?assertMatch({ok, ".\r\n"}, socket:recv(X, 0, 1000)),
socket:send(X, "250 ok\r\n"),
?assertMatch({ok, "QUIT\r\n"}, socket:recv(X, 0, 1000)),
ok
end
}
end,
fun({ListenSock}) ->
{"a valid complete transaction with binary arguments should succeed",
fun() ->
Options = [{relay, "localhost"}, {port, 9876}, {hostname, "testing"}],
{ok, _Pid} = send({<<"test@foo.com">>, [<<"foo@bar.com">>], <<"hello world">>}, Options),
Expand Down

0 comments on commit 1af6543

Please sign in to comment.