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

Conversation

cez81
Copy link
Contributor

@cez81 cez81 commented Oct 17, 2017

As title, fix #2685

Extra arguments are added after the standard arguments ("-F from -i")

@codecov-io
Copy link

codecov-io commented Oct 17, 2017

Codecov Report

Merging #2731 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

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

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3af5b67...bc96313. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 17, 2017
@pgaskin
Copy link
Contributor

pgaskin commented Oct 18, 2017

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.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above

Copy link
Contributor Author

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.

@cez81
Copy link
Contributor Author

cez81 commented Oct 18, 2017

@geek1011 Oops, yes you're right :)

@lafriks lafriks added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/enhancement An improvement of existing functionality and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Oct 18, 2017
@lafriks lafriks added this to the 1.3.0 milestone Oct 18, 2017
@@ -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(" "),
Copy link
Contributor

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.

Copy link
Contributor Author

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

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

@sapk
Copy link
Member

sapk commented Oct 25, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 25, 2017
@lafriks
Copy link
Member

lafriks commented Oct 25, 2017

LGTM

@lafriks
Copy link
Member

lafriks commented Oct 25, 2017

@geek1011 need your approval

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 25, 2017
Copy link
Contributor

@pgaskin pgaskin left a comment

Choose a reason for hiding this comment

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

LGTM

@lafriks
Copy link
Member

lafriks commented Oct 25, 2017

Make LG-TM work again

@lafriks lafriks merged commit e86a0bf into go-gitea:master Oct 25, 2017
@cez81 cez81 deleted the sendmail_options branch October 25, 2017 19:45
vdbt pushed a commit to vdbt/gitea that referenced this pull request Oct 27, 2017
* 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
@msebald
Copy link

msebald commented Oct 29, 2017

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 webmaster@domain.tld

@cez81
Copy link
Contributor Author

cez81 commented Nov 20, 2017

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.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow sendmail options in SENDMAIL_PATH
7 participants