mailgun-response-debug
This commit is contained in:
parent
5af71dfc94
commit
0331d34afc
|
@ -4,10 +4,11 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
// log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/authorizerdev/authorizer/server/constants"
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
)
|
)
|
||||||
|
@ -55,6 +56,15 @@ func MailgunRest(to string, data map[string]interface{}, subject string, templat
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Log the Mailgun API response
|
||||||
|
responseBody, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error reading Mailgun API response: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Mailgun API response: %s", responseBody)
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return fmt.Errorf("failed to send email, status: %d", resp.StatusCode)
|
return fmt.Errorf("failed to send email, status: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
@ -85,5 +95,14 @@ func SendMailgun(to []string, event string, data map[string]interface{}) error {
|
||||||
|
|
||||||
// TODO: language selection logic here
|
// TODO: language selection logic here
|
||||||
|
|
||||||
return MailgunRest(to[0], data, subject, template)
|
err := MailgunRest(to[0], data, subject, template)
|
||||||
|
|
||||||
|
// Log the response
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error sending email: %v", err)
|
||||||
|
} else {
|
||||||
|
log.Println("Email sent successfully")
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user