[bugfix] add Date and Message-ID headers for email (#3031)

* [bugfix] add Date and Message-ID headers for email

This should make spam filters more happy, as most of them grant some
negative score for not having those headers. Also the Date is convenient
for the user receiving the mail.

* make golangci-lint happy
This commit is contained in:
Julian 2024-06-22 23:36:30 +02:00 committed by GitHub
commit c2738474d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 3 deletions

View file

@ -31,6 +31,7 @@ import (
// Passing a nil function is also acceptable, in which case the send functions will just return nil.
func NewNoopSender(sendCallback func(toAddress string, message string)) (Sender, error) {
templateBaseDir := config.GetWebTemplateBaseDir()
msgIDHost := config.GetHost()
t, err := loadTemplates(templateBaseDir)
if err != nil {
@ -39,12 +40,14 @@ func NewNoopSender(sendCallback func(toAddress string, message string)) (Sender,
return &noopSender{
sendCallback: sendCallback,
msgIDHost: msgIDHost,
template: t,
}, nil
}
type noopSender struct {
sendCallback func(toAddress string, message string)
msgIDHost string
template *template.Template
}
@ -86,7 +89,7 @@ func (s *noopSender) sendTemplate(template string, subject string, data any, toA
return err
}
msg, err := assembleMessage(subject, buf.String(), "test@example.org", toAddresses...)
msg, err := assembleMessage(subject, buf.String(), "test@example.org", s.msgIDHost, toAddresses...)
if err != nil {
return err
}