Enable using RSET after transaction failures in deliver/2 #264
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 no
RSET
is needed, but the socket is kept open. Any other unexpected replies will cause a quit.