-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Retrieve textproto.Error When Using gomail.Send() #102
Comments
gomail.Send()
@jordan-wright Could I interest you in opening a pull request fixing this on go-mail#12? |
Hey @ivy! I wound up doing what you did and just making a fork that lives at https://github.com/gophish/gomail. I can probably make a pull req when I get some time, I'll just need to figure out how to cherry-pick that commit for review. |
If it helps, I think this was the commit gophish@28cec6d |
Thanks @jordan-wright. I see you also had a use for I'm hoping to keep some of the error context around with a custom error similar to: // A SendError represents the failed transmission of a Message and details the
// original error and index of the Message if it was part of a batch.
type SendError struct {
// Index specifies the index of the Message, if it was part of a batch.
Index uint
// Cause specifies the error detailing the original cause of the failure.
Cause error
}
func (err *SendError) Error() string {
return fmt.Sprintf("gomail: could not send email %d: %v",
err.Index, err.Cause)
} |
It's useful to retrieve the
*textproto.Error
when sending emails so my client will know how best to handle the error.I see in #37 that this used to be possible, but it looks like future changes wrapped the changes in a generic error string that makes it seemingly impossible to retrieve the original
*textproto.Error
: https://github.com/go-gomail/gomail/blob/master/send.go#L39.I see the value in indicating the index that this error occurred on, but maybe this could be wrapped in a struct that implements the error interface or something? Without the ability to access the underlying error, it's difficult to write a compliant smtp client.
The text was updated successfully, but these errors were encountered: