Browse Source

Fix notification email issues (#4055)

pull/3475/merge
Óscar García Amor 8 years ago committed by 无闻
parent
commit
eaf57229d3
  1. 2
      models/mail.go
  2. 9
      modules/setting/setting.go

2
models/mail.go

@ -160,7 +160,7 @@ func composeIssueMessage(issue *Issue, doer *User, tplName base.TplName, tos []s
if err != nil {
log.Error(3, "HTMLString (%s): %v", tplName, err)
}
msg := mailer.NewMessageFrom(tos, fmt.Sprintf(`"%s" <%s>`, doer.DisplayName(), setting.MailService.User), subject, content)
msg := mailer.NewMessageFrom(tos, fmt.Sprintf(`"%s" <%s>`, doer.DisplayName(), setting.MailService.FromEmail), subject, content)
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
return msg
}

9
modules/setting/setting.go

@ -6,6 +6,7 @@ package setting
import (
"fmt"
"net/mail"
"net/url"
"os"
"os/exec"
@ -721,6 +722,7 @@ type Mailer struct {
Name string
Host string
From string
FromEmail string
User, Passwd string
DisableHelo bool
HeloHostname string
@ -756,6 +758,13 @@ func newMailService() {
EnableHTMLAlternative: sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(),
}
MailService.From = sec.Key("FROM").MustString(MailService.User)
parsed, err := mail.ParseAddress(MailService.From)
if err != nil {
log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
}
MailService.FromEmail = parsed.Address
log.Info("Mail Service Enabled")
}

Loading…
Cancel
Save