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 { switch u.Scheme {
case "imap":
// This space is intentionally left blank
case "imaps": case "imaps":
s.imap.tls = true s.imap.tls = true
case "imap+insecure": case "imap+insecure":
s.imap.insecure = true 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() c, err := s.dialIMAP()
@ -152,16 +156,20 @@ func (s *Server) parseSMTPUpstream() error {
} }
} }
s.smtp.host = u.Host
switch u.Scheme { switch u.Scheme {
case "smtp":
// This space is intentionally left blank
case "smtps": case "smtps":
s.smtp.tls = true s.smtp.tls = true
case "smtp+insecure": case "smtp+insecure":
s.smtp.insecure = true 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() c, err := s.dialSMTP()