Add default ports for IMAP and SMTP

This commit is contained in:
Simon Ser 2020-02-12 16:15:18 +01:00
parent 8299617ebc
commit 243e090bcb
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -114,16 +114,20 @@ func (s *Server) parseIMAPUpstream() error {
}
}
s.imap.host = u.Host
switch u.Scheme {
case "imap":
// This space is intentionally left blank
case "imaps":
s.imap.tls = true
case "imap+insecure":
s.imap.insecure = true
default:
panic("unreachable")
}
s.imap.host = u.Host
if !strings.ContainsRune(s.imap.host, ':') {
if u.Scheme == "imaps" {
s.imap.host += ":993"
} else {
s.imap.host += ":143"
}
}
c, err := s.dialIMAP()
@ -152,16 +156,20 @@ func (s *Server) parseSMTPUpstream() error {
}
}
s.smtp.host = u.Host
switch u.Scheme {
case "smtp":
// This space is intentionally left blank
case "smtps":
s.smtp.tls = true
case "smtp+insecure":
s.smtp.insecure = true
default:
panic("unreachable")
}
s.smtp.host = u.Host
if !strings.ContainsRune(s.smtp.host, ':') {
if u.Scheme == "smtps" {
s.smtp.host += ":465"
} else {
s.smtp.host += ":587"
}
}
c, err := s.dialSMTP()