diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2016-05-15 17:12:42 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2016-05-15 17:12:42 -0700 |
commit | ced3f8648d116cf1bba1ff106093c7148df129ce (patch) | |
tree | 56b66a1768a6933316abc0b21afa815f58002ee7 | |
parent | 53d88470a08f829f5d141219a50f62c37cee4660 (diff) |
Autocorrect auth type for outlook servers
-rw-r--r-- | src/core/smtp/MCSMTPSession.cpp | 19 | ||||
-rw-r--r-- | 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); |