Skip to content

Commit

Permalink
Merge pull request #4 from paganotoni/response-error
Browse files Browse the repository at this point in the history
Returning error if Sendgrid response is not 202
  • Loading branch information
paganotoni authored Dec 19, 2018
2 parents 6de67d1 + 9d16853 commit ae76f13
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sendgrid_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ func (ps SendgridSender) Send(m mail.Message) error {
mm.AddPersonalizations(p)
mm.AddContent(text, html)

_, err = ps.client.Send(mm)
response, err := ps.client.Send(mm)
if response.StatusCode != 202 {
return fmt.Errorf("Error sending email, code %v body %v", response.StatusCode, response.Body)
}

return err
}

Expand Down

0 comments on commit ae76f13

Please sign in to comment.