1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-02 20:15:26 +02:00

Set ReplyTo for SMTP based notifications

Ensure all replies go back to person who initiated the notification.
This commit is contained in:
sauls8t 2018-05-03 18:03:25 +01:00
parent 3b0291d94c
commit 2298ac3376
9 changed files with 720 additions and 697 deletions

View file

@ -88,10 +88,12 @@ func Connect(c Config) (d *mail.Dialer, err error) {
// EmailMessage represents email to be sent.
type EmailMessage struct {
ToEmail string
ToName string
Subject string
BodyHTML string
ToEmail string
ToName string
Subject string
BodyHTML string
ReplyTo string
ReplyName string
}
// SendMessage sends email using specified SMTP connection
@ -102,6 +104,17 @@ func SendMessage(d *mail.Dialer, c Config, em EmailMessage) (b bool, err error)
m.SetHeader("From", m.FormatAddress(c.SenderEmail, c.SenderName))
m.SetHeader("To", m.FormatAddress(em.ToEmail, em.ToName))
// Where do replies go?
reply := c.SenderEmail
replyName := c.SenderName
if len(em.ReplyTo) > 0 {
reply = em.ReplyTo
}
if len(em.ReplyName) > 0 {
replyName = em.ReplyName
}
m.SetAddressHeader("Reply-To", reply, replyName)
// content
m.SetHeader("Subject", em.Subject)
m.SetBody("text/html", em.BodyHTML)