0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 07:44:18 +01:00

Fix sender of issue notifications

It is the FROM field in mailer configuration that needs be used,
not the USER field, which is for authentication.

Closes https://github.com/gogits/gogs/issues/3615
This commit is contained in:
Sandro Santilli 2016-09-07 11:19:44 +02:00
parent 5c54243014
commit af03d00780
2 changed files with 10 additions and 1 deletions

View file

@ -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
}

View file

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