aboutsummaryrefslogtreecommitdiff
path: root/internal/imap/imap.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/imap/imap.go')
-rw-r--r--internal/imap/imap.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 8f4c50e..f8c8632 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -11,20 +11,23 @@ import (
)
func newImapClient(url *URL, forceTls bool) (*imapClient.Client, error) {
+ var (
+ c *imapClient.Client
+ err error
+ )
+
if forceTls {
- c, err := imapClient.DialTLS(url.Host, nil)
- if err != nil {
+ if c, err = imapClient.DialTLS(url.Host, nil); err != nil {
return nil, fmt.Errorf("connecting (TLS) to %s: %w", url.Host, err)
}
log.Print("Connected to ", url.Host, " (TLS)")
- return c, nil
} else {
- c, err := imapClient.Dial(url.Host)
- if err != nil {
+ if c, err = imapClient.Dial(url.Host); err != nil {
return nil, fmt.Errorf("connecting to %s: %w", url.Host, err)
}
- return c, nil
}
+
+ return c, nil
}
func (client *Client) connect(url *URL, forceTls bool) (*connection, error) {