From dac581a7eb870739f76ce50e70ec507eb3a57681 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Thu, 22 Jun 2017 19:22:35 -0500 Subject: [PATCH] Adding "Content-ID" headers to attachments to help support possible embedded images. Addresses #251 --- worker/worker.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worker/worker.go b/worker/worker.go index f3e7f3c7..494ee6b0 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -6,6 +6,7 @@ import ( "encoding/base64" "encoding/json" "errors" + "fmt" "io" "log" "net/mail" @@ -199,12 +200,13 @@ func processCampaign(c *models.Campaign) { } // Attach the files for _, a := range c.Template.Attachments { - e.Attach(func(a models.Attachment) (string, gomail.FileSetting) { + e.Attach(func(a models.Attachment) (string, gomail.FileSetting, gomail.FileSetting) { + h := map[string][]string{"Content-ID": {fmt.Sprintf("<%s>", a.Name)}} return a.Name, gomail.SetCopyFunc(func(w io.Writer) error { decoder := base64.NewDecoder(base64.StdEncoding, strings.NewReader(a.Content)) _, err = io.Copy(w, decoder) return err - }) + }), gomail.SetHeader(h) }(a)) } Logger.Printf("Sending Email to %s\n", t.Email)