diff options
author | zeripath <art27@cantab.net> | 2021-11-19 15:35:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 23:35:20 +0800 |
commit | 38347aa16f7cfb32bb984ade4518bd311d0aff12 (patch) | |
tree | b1566f8cb2a481162b799e86308eb522d51f33e1 /services/mailer | |
parent | d4e281bc02908f5e1dda3dc4d340e2898048faef (diff) | |
download | gitea-38347aa16f7cfb32bb984ade4518bd311d0aff12.tar.gz gitea-38347aa16f7cfb32bb984ade4518bd311d0aff12.zip |
Add settings to allow different SMTP envelope from address (#17479)
* Add settings to allow different SMTP envelope from address
Sometimes it may be advisable to hide or alias the from address on an SMTP mail
envelope. This PR adds two new options to the mailer to allow setting of an overriding
from address.
Fix #17477
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/mailer')
-rw-r--r-- | services/mailer/mailer.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index fae8d473e3..0c0c626627 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -210,8 +210,14 @@ func (s *smtpSender) Send(from string, to []string, msg io.WriterTo) error { } } - if err = client.Mail(from); err != nil { - return fmt.Errorf("Mail: %v", err) + if opts.OverrideEnvelopeFrom { + if err = client.Mail(opts.EnvelopeFrom); err != nil { + return fmt.Errorf("Mail: %v", err) + } + } else { + if err = client.Mail(from); err != nil { + return fmt.Errorf("Mail: %v", err) + } } for _, rec := range to { @@ -242,7 +248,12 @@ func (s *sendmailSender) Send(from string, to []string, msg io.WriterTo) error { var closeError error var waitError error - args := []string{"-f", from, "-i"} + envelopeFrom := from + if setting.MailService.OverrideEnvelopeFrom { + envelopeFrom = setting.MailService.EnvelopeFrom + } + + args := []string{"-f", envelopeFrom, "-i"} args = append(args, setting.MailService.SendmailArgs...) args = append(args, to...) log.Trace("Sending with: %s %v", setting.MailService.SendmailPath, args) |