Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extra sendmail arguments #2731

Merged
merged 6 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/app.ini
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ SEND_AS_PLAIN_TEXT = false
USE_SENDMAIL = false
; Specify an alternative sendmail binary
SENDMAIL_PATH = sendmail
; Specify any extra sendmail arguments
SENDMAIL_ARGS =

[cache]
; Either "memory", "redis", or "memcache", default is "memory"
Expand Down
1 change: 1 addition & 0 deletions modules/mailer/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
7 changes: 7 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -1326,6 +1327,7 @@ type Mailer struct {
// Sendmail sender
UseSendmail bool
SendmailPath string
SendmailArgs []string
}

var (
Expand Down Expand Up @@ -1372,6 +1374,11 @@ func newMailService() {
MailService.FromName = parsed.Name
MailService.FromEmail = parsed.Address

MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
Copy link
Member

@lafriks lafriks Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be it's worth load this (and also parse ) only if MailService.UseSendmail is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if err != nil && MailService.UseSendmail {
log.Error(4, "Failed to parse Sendmail args: %v", CustomConf, err)
}

log.Info("Mail Service Enabled")
}

Expand Down
19 changes: 19 additions & 0 deletions vendor/github.com/kballard/go-shellquote/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions vendor/github.com/kballard/go-shellquote/README

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/github.com/kballard/go-shellquote/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions vendor/github.com/kballard/go-shellquote/quote.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

144 changes: 144 additions & 0 deletions vendor/github.com/kballard/go-shellquote/unquote.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@
"revision": "b2c7a7da5b2995941048f60146e67702a292e468",
"revisionTime": "2016-02-12T04:00:40Z"
},
{
"checksumSHA1": "+IzngblnBQNh+GmsS2O7jqmzSVQ=",
"path": "github.com/kballard/go-shellquote",
"revision": "cd60e84ee657ff3dc51de0b4f55dd299a3e136f2",
"revisionTime": "2017-06-19T18:30:22Z"
},
{
"checksumSHA1": "VJk3rOWfxEV9Ilig5lgzH1qg8Ss=",
"path": "github.com/keybase/go-crypto/brainpool",
Expand Down