From ced3f8648d116cf1bba1ff106093c7148df129ce Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Sun, 15 May 2016 17:12:42 -0700 Subject: Autocorrect auth type for outlook servers --- src/core/smtp/MCSMTPSession.cpp | 19 +++++++++++++++++-- src/core/smtp/MCSMTPSession.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/core/smtp/MCSMTPSession.cpp b/src/core/smtp/MCSMTPSession.cpp index 501bddde..b75ec215 100644 --- a/src/core/smtp/MCSMTPSession.cpp +++ b/src/core/smtp/MCSMTPSession.cpp @@ -53,6 +53,8 @@ void SMTPSession::init() pthread_mutex_init(&mConnectionLoggerLock, NULL); pthread_mutex_init(&mCancelLock, NULL); pthread_mutex_init(&mCanCancelLock, NULL); + + mOutlookServer = true; } SMTPSession::SMTPSession() @@ -286,7 +288,13 @@ void SMTPSession::connect(ErrorCode * pError) int r; setup(); - + + if (hostname() != NULL) { + if (hostname()->lowercaseString()->isEqual(MCSTR("smtp-mail.outlook.com"))) { + mOutlookServer = true; + } + } + switch (mConnectionType) { case ConnectionTypeStartTLS: MCLog("connect %s %u", MCUTF8(hostname()), (unsigned int) port()); @@ -502,7 +510,14 @@ void SMTPSession::login(ErrorCode * pError) } } - switch (authType()) { + AuthType correctedAuthType = authType(); + if (mOutlookServer) { + if (correctedAuthType == AuthTypeXOAuth2) { + correctedAuthType = AuthTypeXOAuth2Outlook; + } + } + + switch (correctedAuthType) { case 0: default: r = mailesmtp_auth_sasl(mSmtp, "PLAIN", diff --git a/src/core/smtp/MCSMTPSession.h b/src/core/smtp/MCSMTPSession.h index b443fd3e..1330c797 100644 --- a/src/core/smtp/MCSMTPSession.h +++ b/src/core/smtp/MCSMTPSession.h @@ -106,6 +106,8 @@ namespace mailcore { ConnectionLogger * mConnectionLogger; pthread_mutex_t mConnectionLoggerLock; + bool mOutlookServer; + void init(); Data * dataWithFilteredBcc(Data * data); static void body_progress(size_t current, size_t maximum, void * context); -- cgit v1.2.3