-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2731 +/- ##
=======================================
Coverage 27.08% 27.08%
=======================================
Files 88 88
Lines 17264 17264
=======================================
Hits 4676 4676
Misses 11909 11909
Partials 679 679 Continue to review full report at Codecov.
|
a1f8dee
to
52c452a
Compare
Shouldn't you tokenize the arguments in the config, lest they be passed to sendmail as one long argument? You would need to split the arguments in the config into a slice, keeping in mind escaping and quoting. There may be a lib to do this. |
modules/mailer/mailer.go
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just splitting it seems to be good enough unless nothing to fancy pancy? Same is done for args to GC and health check.
@geek1011 Oops, yes you're right :) |
modules/setting/setting.go
Outdated
@@ -1344,6 +1345,7 @@ func newMailService() { | |||
|
|||
UseSendmail: sec.Key("USE_SENDMAIL").MustBool(), | |||
SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"), | |||
SendmailArgs: sec.Key("SENDMAIL_ARGS").Strings(" "), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cez81 this does not handle quoted or escaped strings I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geek1011 New commits to use go-shellquote library
dce921e
to
2cbac8c
Compare
modules/setting/setting.go
Outdated
@@ -1372,6 +1374,11 @@ func newMailService() { | |||
MailService.FromName = parsed.Name | |||
MailService.FromEmail = parsed.Address | |||
|
|||
MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
LGTM |
LGTM |
@geek1011 need your approval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Make LG-TM work again |
* 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
Great, thank you. How do I use it in the config? If I put the following there is no difference when sending out the test mail: SENDMAIL_ARGS = -t -i -f [email protected] |
Something like that should work. You could try -X /tmp/sendmail.log and see what goes wrong. -F and -i are set by default in the code. |
As title, fix #2685
Extra arguments are added after the standard arguments ("-F from -i")