Don't lookup mail server when using sendmail (#22300)

Fix #22287
forgejo
Lunny Xiao 1 year ago committed by GitHub
parent 82235fb681
commit 99a675f4a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -178,6 +178,15 @@ 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
// 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 {
@ -187,6 +196,8 @@ func newMailService() {
}
}
}
case "dummy": // just mention and do nothing
}
if MailService.From != "" {
parsed, err := mail.ParseAddress(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")
}

Loading…
Cancel
Save