Skip to content

Commit

Permalink
Merge pull request #2 from strk/proper-from-on-issue-mail
Browse files Browse the repository at this point in the history
Fix sender of issue notifications
  • Loading branch information
lunny committed Nov 3, 2016
2 parents 5c54243 + af03d00 commit d8de2be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion models/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package setting

import (
"fmt"
"net/mail"
"net/url"
"os"
"os/exec"
Expand Down Expand Up @@ -714,6 +715,7 @@ type Mailer struct {
Name string
Host string
From string
FromEmail string
User, Passwd string
DisableHelo bool
HeloHostname string
Expand Down Expand Up @@ -749,6 +751,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")
}

Expand Down

0 comments on commit d8de2be

Please sign in to comment.