Initial test email works.

This commit is contained in:
Eli Ribble 2026-01-18 03:00:48 +00:00
parent 7abaebe496
commit 4e294699d3
No known key found for this signature in database
3 changed files with 51 additions and 45 deletions

View file

@ -13,22 +13,22 @@ import (
type AttachmentRequest struct {
Filename string `json:"filename"`
Content string `json:"content"`
Content string `json:"content"`
}
type EmailRequest struct {
From string `json:"from"`
To string `json:"to"`
CC []string `json:"cc,omitempty"`
BCC []string `json:"bcc,omitempty"`
Subject string `json:"subject"`
Text string `json:"text"`
HTML string `json:"html,omitempty"`
From string `json:"from"`
To string `json:"to"`
CC []string `json:"cc,omitempty"`
BCC []string `json:"bcc,omitempty"`
Subject string `json:"subject"`
Text string `json:"text"`
HTML string `json:"html,omitempty"`
Attachments []AttachmentRequest `json:"attachments,omitempty"`
Sender string `json:"sender"`
ReplyTo string `json:"replyTo,omitempty"`
InReplyTo string `json:"inReplyTo,omitempty"`
References []string `json:"references,omitempty"`
Sender string `json:"sender"`
ReplyTo string `json:"replyTo,omitempty"`
InReplyTo string `json:"inReplyTo,omitempty"`
References []string `json:"references,omitempty"`
}
type EmailResponse struct {
@ -42,7 +42,6 @@ func SendEmail(email EmailRequest) error {
if err != nil {
return fmt.Errorf("Failed to marshal email request: %w", err)
}
//payload := strings.NewReader("{\n \"from\": \"\",\n \"to\": \"\",\n \"cc\": \"\",\n \"bcc\": \"\",\n \"subject\": \"\",\n \"text\": \"\",\n \"html\": \"\",\n \"attachments\": [\n {}\n ],\n \"sender\": \"\",\n \"replyTo\": \"\",\n \"inReplyTo\": \"\",\n \"references\": \"\",\n \"attachDataUrls\": true,\n \"watchHtml\": \"\",\n \"amp\": \"\",\n \"icalEvent\": {},\n \"alternatives\": [\n {}\n ],\n \"encoding\": \"\",\n \"raw\": \"\",\n \"textEncoding\": \"quoted-printable\",\n \"priority\": \"high\",\n \"headers\": {\"ANY_ADDITIONAL_PROPERTY\": \"anything\"},\n \"messageId\": \"\",\n \"date\": \"\",\n \"list\": {},\n \"requireTLS\": true\n}")
req, _ := http.NewRequest("POST", url, bytes.NewReader(payload))
req.SetBasicAuth(config.ForwardEmailAPIToken, "")
@ -53,6 +52,6 @@ func SendEmail(email EmailRequest) error {
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
log.Info().Str("status", res.Status).Str("request_body", string(payload)).Str("response_body", string(body)).Msg("Attempted to send email")
log.Info().Str("status", res.Status).Str("response_body", string(body)).Msg("Attempted to send email")
return nil
}