v0.3.7: Improved delivery error handling #92
Closed
wneessen
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This release introduces the
SendError
type which satisfies the error interface and provides a better way to identify delivery errors. A newsendError
field has been added to theMsg
as well, to also allow per-message error handling in bulk mailings.We've also added different
SendErrReason
that indicate the different things that can go wrong during mail delivery. These reasons can be checked for, for eachMsg
using theerrors.Is
methods. Alternatively, theerrors.As
method can be used to unwrap theSendError
to get access to it's methods. TheSendError
provides aIsTemp
method that returns true if the delivery error is of temporary nature.This is useful for delivery retries. For example the following code could be used to decide whether the error is retryable or not:
If the
Send
method runs into more than one error during delivery, these errors are accumulated and returned with the reasonErrAmbiguous
, since it's not possible to exactly say what caused the error. For this it comes handy, that the*Msg
now provides per-message send errors. The*Msg
now hasHasSendError()
,SendErrorIsTemp()
andSendError()
. WhileHasSendError()
simply returns a bool in case a*Msg
failed during delivery andSendErrorIsTemp()
returns true if it's a temporary error, theSendError()
will return the fullSendError
error of the corresponding*Msg
.The
Error()
method ofSendError
will return a detailed error string based on the accumulated errors that were collected during the delivery.Thanks to @imirkin and @iwittkau for providing valueable feedback and performing code review on the PR.
What's Changed
Full Changelog: v0.3.6...v0.3.7
This discussion was created from the release v0.3.7: Improved delivery error handling.
Beta Was this translation helpful? Give feedback.
All reactions