Skip to content

armgit / posta

Public Imported from GitHub
0

Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.

fix(email): fix subject UTF-8 encoding

Jonas Kanindaac48fee81ee8
diff --git a/internal/services/email/smtp_sender.go b/internal/services/email/smtp_sender.go
index a7b235f..71c64d3 100644
--- a/internal/services/email/smtp_sender.go
+++ b/internal/services/email/smtp_sender.go
@@ -21,6 +21,7 @@ import (
"crypto/tls"
"encoding/base64"
"fmt"
+ "mime"
"net/mail"
"net/smtp"
"strings"
@@ -182,7 +183,7 @@ func buildMessage(from string, to []string, subject, htmlBody, textBody string,
fmt.Fprintf(&b, "From: %s\r\n", from)
fmt.Fprintf(&b, "To: %s\r\n", strings.Join(to, ", "))
- fmt.Fprintf(&b, "Subject: %s\r\n", subject)
+ fmt.Fprintf(&b, "Subject: %s\r\n", mime.QEncoding.Encode("UTF-8", subject))
b.WriteString("MIME-Version: 1.0\r\n")
// RFC 8058: List-Unsubscribe headers