Add support for extra sendmail arguments (#2731)

* Add support for extra sendmail arguments

* Sendmail args to exec.command should be a list

* Add go-shellquote package

* Use go-shellquote lib for parsing Sendmail args

* Only parse if sendmail is configured
This commit is contained in:
Jonas Bröms 2017-10-25 21:27:25 +02:00 committed by Lauris BH
parent 3af5b67ed0
commit e86a0bf3fe
9 changed files with 322 additions and 0 deletions

View file

@ -35,6 +35,7 @@ import (
"github.com/go-macaron/session"
_ "github.com/go-macaron/session/redis" // redis plugin for store session
"github.com/go-xorm/core"
"github.com/kballard/go-shellquote"
"gopkg.in/ini.v1"
"strk.kbt.io/projects/go/libravatar"
)
@ -1326,6 +1327,7 @@ type Mailer struct {
// Sendmail sender
UseSendmail bool
SendmailPath string
SendmailArgs []string
}
var (
@ -1372,6 +1374,13 @@ func newMailService() {
MailService.FromName = parsed.Name
MailService.FromEmail = parsed.Address
if MailService.UseSendmail {
MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
if err != nil {
log.Error(4, "Failed to parse Sendmail args: %v", CustomConf, err)
}
}
log.Info("Mail Service Enabled")
}