From 2dc7bee92aecbf139152ee6a34fc66e2a57065ab Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Thu, 23 Jan 2025 19:34:26 +0000 Subject: [PATCH] 4273 - courier http channel - Include error response from email service provider in courier logs This change includes error response sent by email service provider when http channel is used and email sending fails due to some reason. Currently only response code is included in courier logs when email sending api call is made. This makes it hard to obtain further information on the actual error. --- courier/http_channel.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/courier/http_channel.go b/courier/http_channel.go index 97df749e48ae..de45209a1f4e 100644 --- a/courier/http_channel.go +++ b/courier/http_channel.go @@ -4,6 +4,7 @@ package courier import ( + "bytes" "context" "encoding/json" "fmt" @@ -105,9 +106,11 @@ func (c *httpChannel) Dispatch(ctx context.Context, msg Message) (err error) { } err = errors.Errorf( - "unable to dispatch mail delivery because upstream server replied with status code %d", - res.StatusCode, + "unable to dispatch mail delivery because upstream server replied with status code %d and body: %s", + res.StatusCode, + bytes.NewBuffer(x.MustReadAll(res.Body)).String(), ) + logger. WithError(err). Error("sending mail via HTTP failed.")