feat(mail): one layout for all mails with logo, greeting, cards and footer
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m1s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m1s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df06ab10c8
commit
46e1137f18
16 files changed
+475
-60
No files matched your search
+22
-1
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -147,7 +148,27 @@ func buildMessage(from, to, subject, body, html string, now time.Time) []byte {
|
||||
fmt.Fprintf(&buf, "--%s\r\n", boundary)
|
||||
part("text/plain", body)
|
||||
fmt.Fprintf(&buf, "--%s\r\n", boundary)
|
||||
part("text/html", html)
|
||||
if strings.Contains(html, "cid:"+mailLogoCID) {
|
||||
// The HTML shows the logo from inside the mail: HTML and image together as multipart/related
|
||||
related := boundary + "-rel"
|
||||
fmt.Fprintf(&buf, "Content-Type: multipart/related; boundary=\"%s\"\r\n\r\n", related)
|
||||
fmt.Fprintf(&buf, "--%s\r\n", related)
|
||||
part("text/html", html)
|
||||
fmt.Fprintf(&buf, "--%s\r\n", related)
|
||||
buf.WriteString("Content-Type: image/png; name=\"mindsift.png\"\r\n")
|
||||
buf.WriteString("Content-Transfer-Encoding: base64\r\n")
|
||||
fmt.Fprintf(&buf, "Content-ID: <%s>\r\n", mailLogoCID)
|
||||
buf.WriteString("Content-Disposition: inline; filename=\"mindsift.png\"\r\n\r\n")
|
||||
enc := base64.StdEncoding.EncodeToString(mailLogoPNG)
|
||||
for len(enc) > 76 {
|
||||
buf.WriteString(enc[:76] + "\r\n")
|
||||
enc = enc[76:]
|
||||
}
|
||||
buf.WriteString(enc + "\r\n")
|
||||
fmt.Fprintf(&buf, "--%s--\r\n", related)
|
||||
} else {
|
||||
part("text/html", html)
|
||||
}
|
||||
fmt.Fprintf(&buf, "--%s--\r\n", boundary)
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user