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