summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJonas Bröms <cez81@users.noreply.github.com>2017-10-25 21:27:25 +0200
committerLauris BH <lauris@nix.lv>2017-10-25 22:27:25 +0300
commite86a0bf3feab82c1b3439806245083dffb2f37c9 (patch)
tree8c47d111db8214dbbf3c291a43ad5793a49874b2 /modules
parent3af5b67ed030f84c7269d091add9e476537d30d7 (diff)
downloadgitea-e86a0bf3feab82c1b3439806245083dffb2f37c9.tar.gz
gitea-e86a0bf3feab82c1b3439806245083dffb2f37c9.zip
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
Diffstat (limited to 'modules')
-rw-r--r--modules/mailer/mailer.go1
-rw-r--r--modules/setting/setting.go9
2 files changed, 10 insertions, 0 deletions
diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go
index 0bb78de92a..a54e836173 100644
--- a/modules/mailer/mailer.go
+++ b/modules/mailer/mailer.go
@@ -209,6 +209,7 @@ func (s *sendmailSender) Send(from string, to []string, msg io.WriterTo) error {
var waitError error
args := []string{"-F", from, "-i"}
+ args = append(args, setting.MailService.SendmailArgs...)
args = append(args, to...)
log.Trace("Sending with: %s %v", setting.MailService.SendmailPath, args)
cmd := exec.Command(setting.MailService.SendmailPath, args...)
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index cb8cf7d39a..7706ee3e95 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -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")
}