diff options
author | Simon Ser <contact@emersion.fr> | 2020-02-19 09:43:01 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-02-19 09:43:01 +0100 |
commit | bfb2d8a4de34ce315a7ca5fc62d2ce4c6630e939 (patch) | |
tree | 3afdf107b5723fa9f46d01ace1b3e23e5758ff39 | |
parent | 75122a175a415663fc4f84c2f837129173de59aa (diff) | |
download | alps-bfb2d8a4de34ce315a7ca5fc62d2ce4c6630e939.tar.gz alps-bfb2d8a4de34ce315a7ca5fc62d2ce4c6630e939.zip |
Add discovery support for SMTP with implicit TLS
-rw-r--r-- | discover.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/discover.go b/discover.go index 08d4aa1..297d9ad 100644 --- a/discover.go +++ b/discover.go @@ -53,14 +53,24 @@ func discoverIMAP(domain string) (*url.URL, error) { } // discoverSMTP performs a DNS-based SMTP submission service discovery, as -// defined in RFC 6186 section 3.1. +// defined in RFC 6186 section 3.1. RFC 8314 section 5.1 adds a new service for +// SMTP submission with implicit TLS. func discoverSMTP(domain string) (*url.URL, error) { - host, err := discoverTCP("submission", domain) + smtpsHost, err := discoverTCP("submissions", domain) if err != nil { return nil, err } - if host == "" { - return nil, fmt.Errorf("SMTP service discovery not configured for domain %q", domain) + if smtpsHost != "" { + return &url.URL{Scheme: "smtps", Host: smtpsHost}, nil } - return &url.URL{Scheme: "smtp", Host: host}, nil + + smtpHost, err := discoverTCP("submission", domain) + if err != nil { + return nil, err + } + if smtpHost != "" { + return &url.URL{Scheme: "smtp", Host: smtpHost}, nil + } + + return nil, fmt.Errorf("SMTP service discovery not configured for domain %q", domain) } |