Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Merge branch 'dev'

Jackf29310ba8835
diff --cc core/internal/service/public/common.go
index 0b13dbea,49c97366..3985a871
--- a/core/internal/service/public/common.go
+++ b/core/internal/service/public/common.go
@@@ -2450,7 -2450,27 +2450,32 @@@ func SanitizeUTF8(s string) string
return string(result)
}
+ func AddUnsubscribeButton(content string) string {
+ // Unsubscribe button HTML
+ unsubscribeButton := `<div style="padding: 16px 0; text-align: center"><a href="__UNSUBSCRIBE_URL__" style="color: #ccc; font-size: 12px">Unsubscribe</a></div>`
+
+ // If content already contains unsubscribe link, return directly
+ if strings.Contains(content, "__UNSUBSCRIBE_URL__") {
+ return content
+ }
+
+ // check if content has body tag
+ hasBodyTag := strings.Contains(content, "</body>")
+ hasHtmlTag := strings.Contains(content, "</html>")
+
+ if hasBodyTag {
+ return strings.Replace(content, "</body>", unsubscribeButton+"</body>", 1)
+ }
+
+ if hasHtmlTag {
+ return strings.Replace(content, "</html>", unsubscribeButton+"</html>", 1)
+ }
+
+ // if content has no body tag or html tag, add a complete html framework
+ return fmt.Sprintf(`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><div style="width: 100%%; max-width: 600px; margin: 0 auto;">%s%s</div></body></html>`, content, unsubscribeButton)
+ }
++
+// FormatMX format the email domain
+func FormatMX(domain string) string {
+ return "mail." + strings.TrimPrefix(domain, "mail.")
+}