mirror of
https://github.com/knadh/listmonk.git
synced 2024-09-20 07:16:33 +08:00
parse cc and bcc from custom headers to add them on email envelope (#1865)
This commit is contained in:
parent
6886878ec5
commit
3babd9020e
|
@ -6,6 +6,7 @@ import (
|
|||
"math/rand"
|
||||
"net/smtp"
|
||||
"net/textproto"
|
||||
"strings"
|
||||
|
||||
"github.com/knadh/listmonk/models"
|
||||
"github.com/knadh/smtppool"
|
||||
|
@ -14,6 +15,8 @@ import (
|
|||
const (
|
||||
emName = "email"
|
||||
hdrReturnPath = "Return-Path"
|
||||
hdrBcc = "Bcc"
|
||||
hdrCc = "Cc"
|
||||
)
|
||||
|
||||
// Server represents an SMTP server's credentials.
|
||||
|
@ -146,6 +149,22 @@ func (e *Emailer) Push(m models.Message) error {
|
|||
em.Headers.Del(hdrReturnPath)
|
||||
}
|
||||
|
||||
// If the `Bcc` header is set, it should be set on the Envelope
|
||||
if bcc := em.Headers.Get(hdrBcc); bcc != "" {
|
||||
for _, part := range strings.Split(bcc, ",") {
|
||||
em.Bcc = append(em.Bcc, strings.TrimSpace(part))
|
||||
}
|
||||
em.Headers.Del(hdrBcc)
|
||||
}
|
||||
|
||||
// If the `Cc` header is set, it should be set on the Envelope
|
||||
if cc := em.Headers.Get(hdrCc); cc != "" {
|
||||
for _, part := range strings.Split(cc, ",") {
|
||||
em.Cc = append(em.Cc, strings.TrimSpace(part))
|
||||
}
|
||||
em.Headers.Del(hdrCc)
|
||||
}
|
||||
|
||||
switch m.ContentType {
|
||||
case "plain":
|
||||
em.Text = []byte(m.Body)
|
||||
|
|
Loading…
Reference in a new issue