@@ -178,14 +178,25 @@ func newMailService() {
178
178
179
179
// we want to warn if users use SMTP on a non-local IP;
180
180
// we might as well take the opportunity to check that it has an IP at all
181
- ips := tryResolveAddr (MailService .SMTPAddr )
182
- if MailService .Protocol == "smtp" {
183
- for _ , ip := range ips {
184
- if ! ip .IsLoopback () {
185
- log .Warn ("connecting over insecure SMTP protocol to non-local address is not recommended" )
186
- break
181
+ // This check is not needed for sendmail
182
+ switch MailService .Protocol {
183
+ case "sendmail" :
184
+ var err error
185
+ MailService .SendmailArgs , err = shellquote .Split (sec .Key ("SENDMAIL_ARGS" ).String ())
186
+ if err != nil {
187
+ log .Error ("Failed to parse Sendmail args: '%s' with error %v" , sec .Key ("SENDMAIL_ARGS" ).String (), err )
188
+ }
189
+ case "smtp" , "smtps" , "smtp+starttls" , "smtp+unix" :
190
+ ips := tryResolveAddr (MailService .SMTPAddr )
191
+ if MailService .Protocol == "smtp" {
192
+ for _ , ip := range ips {
193
+ if ! ip .IsLoopback () {
194
+ log .Warn ("connecting over insecure SMTP protocol to non-local address is not recommended" )
195
+ break
196
+ }
187
197
}
188
198
}
199
+ case "dummy" : // just mention and do nothing
189
200
}
190
201
191
202
if MailService .From != "" {
@@ -214,14 +225,6 @@ func newMailService() {
214
225
MailService .EnvelopeFrom = parsed .Address
215
226
}
216
227
217
- if MailService .Protocol == "sendmail" {
218
- var err error
219
- MailService .SendmailArgs , err = shellquote .Split (sec .Key ("SENDMAIL_ARGS" ).String ())
220
- if err != nil {
221
- log .Error ("Failed to parse Sendmail args: %s with error %v" , CustomConf , err )
222
- }
223
- }
224
-
225
228
log .Info ("Mail Service Enabled" )
226
229
}
227
230
0 commit comments