Closed juhlig closed 3 years ago
Hi, thanks for your PR and sorry for not reviewing it for so long. I think it's a great idea, but I think it would be really nice if you will add a couple of tests where you set this option to reset
and assert that the behaviour is different.
Hi, thanks for your PR and sorry for not reviewing it for so long.
No problem :)
I think it's a great idea, but I think it would be really nice if you will add a couple of tests where you set this option to
reset
and assert that the behaviour is different.
I added two tests, one for RSET, one for QUIT. They are a bit more complicated than the others, the feature can only be tested fully with deliver
to see that the connection stays open (or gets closed), not with send
which implicitly closes the connection.
The current client implementation of
gen_smtp_client:deliver/2
always quits the connection to the server when it receives a failure reply in answer toMAIL FROM
,RCPT TO
,DATA
, or the mail body. Instead,RSET
could be used to reset (ie cancel) the transaction and keep the connection open.This PR introduces the option
on_transaction_error
which can be used in agen_smtp_client:open/1
call. Possible values arequit
(the default, resulting in the current behavior) andreset
.When
reset
is given for this option, the client will try to issue aRSET
command after receiving a4xx
or5xx
response code in answer toMAIL FROM
,RCPT TO
orDATA
(other unexpected replies will cause a quit), and leave the socket connected if the server replies with250
to theRSET
command (otherwise it will quit). If it receives a 4xx or 5xx response after sending the mail body, the transaction is already finished and noRSET
is needed, but the socket is kept open. Any other unexpected replies will cause a quit.