Fix santa bug, email subject encoding, closes #65

This commit is contained in:
Philipp Heckel 2021-12-26 14:34:25 +01:00
parent 9a0f1f22b8
commit ec7e58a6a2
2 changed files with 20 additions and 17 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"heckel.io/ntfy/util"
"mime"
"net"
"net/smtp"
"strings"
@ -28,6 +29,7 @@ func (s *smtpMailer) Send(senderIP, to string, m *message) error {
if err != nil {
return err
}
println(message)
auth := smtp.PlainAuth("", s.config.SMTPUser, s.config.SMTPPass, host)
return smtp.SendMail(s.config.SMTPAddr, auth, s.config.SMTPFrom, []string{to}, []byte(message))
}
@ -66,10 +68,11 @@ func formatMail(baseURL, senderIP, from, to string, m *message) (string, error)
if trailer != "" {
message += "\n\n" + trailer
}
body := `Content-Type: text/plain; charset="utf-8"
From: "{shortTopicURL}" <{from}>
subject = mime.BEncoding.Encode("utf-8", subject)
body := `From: "{shortTopicURL}" <{from}>
To: {to}
Subject: {subject}
Content-Type: text/plain; charset="utf-8"
{message}