summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-10 00:09:46 +0800
committerGitHub <noreply@github.com>2023-01-09 11:09:46 -0500
commit99a675f4a1fc32339e9b93ea33207322c3e8bef1 (patch)
tree061226e6a791218e646125098a6ef4c8b88411a2 /modules/setting
parent82235fb6817a310b165275d304c84f049011e296 (diff)
downloadgitea-99a675f4a1fc32339e9b93ea33207322c3e8bef1.tar.gz
gitea-99a675f4a1fc32339e9b93ea33207322c3e8bef1.zip
Don't lookup mail server when using sendmail (#22300)
Fix #22287
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/mailer.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go
index 7324328ee3..e7cc812eef 100644
--- a/modules/setting/mailer.go
+++ b/modules/setting/mailer.go
@@ -178,14 +178,25 @@ func newMailService() {
// we want to warn if users use SMTP on a non-local IP;
// we might as well take the opportunity to check that it has an IP at all
- ips := tryResolveAddr(MailService.SMTPAddr)
- if MailService.Protocol == "smtp" {
- for _, ip := range ips {
- if !ip.IsLoopback() {
- log.Warn("connecting over insecure SMTP protocol to non-local address is not recommended")
- break
+ // This check is not needed for sendmail
+ switch MailService.Protocol {
+ case "sendmail":
+ var err error
+ MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
+ if err != nil {
+ log.Error("Failed to parse Sendmail args: '%s' with error %v", sec.Key("SENDMAIL_ARGS").String(), err)
+ }
+ case "smtp", "smtps", "smtp+starttls", "smtp+unix":
+ ips := tryResolveAddr(MailService.SMTPAddr)
+ if MailService.Protocol == "smtp" {
+ for _, ip := range ips {
+ if !ip.IsLoopback() {
+ log.Warn("connecting over insecure SMTP protocol to non-local address is not recommended")
+ break
+ }
}
}
+ case "dummy": // just mention and do nothing
}
if MailService.From != "" {
@@ -214,14 +225,6 @@ func newMailService() {
MailService.EnvelopeFrom = parsed.Address
}
- if MailService.Protocol == "sendmail" {
- var err error
- MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
- if err != nil {
- log.Error("Failed to parse Sendmail args: %s with error %v", CustomConf, err)
- }
- }
-
log.Info("Mail Service Enabled")
}