summaryrefslogtreecommitdiff
path: root/Userland/Applications/Mail/MailWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications/Mail/MailWidget.cpp')
-rw-r--r--Userland/Applications/Mail/MailWidget.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp
index 996246d652..15c01513f7 100644
--- a/Userland/Applications/Mail/MailWidget.cpp
+++ b/Userland/Applications/Mail/MailWidget.cpp
@@ -126,12 +126,15 @@ bool MailWidget::connect_and_login()
return false;
}
- m_imap_client = make<IMAP::Client>(server, port, tls);
- auto connection_promise = m_imap_client->connect();
- if (!connection_promise) {
- GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}.", server, port, tls ? "TLS" : "Plaintext"));
+ auto maybe_imap_client = tls ? IMAP::Client::connect_tls(server, port) : IMAP::Client::connect_plaintext(server, port);
+ if (maybe_imap_client.is_error()) {
+ GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}: {}", server, port, tls ? "TLS" : "Plaintext", maybe_imap_client.error()));
return false;
}
+ m_imap_client = maybe_imap_client.release_value();
+
+ auto connection_promise = m_imap_client->connection_promise();
+ VERIFY(!connection_promise.is_null());
connection_promise->await();
auto response = m_imap_client->login(username, password)->await().release_value();