From c9805d7e39a4ec19d5d22b9148f5e6852a15de47 Mon Sep 17 00:00:00 2001 From: Sergei Epatov Date: Tue, 26 Jan 2016 21:57:18 +0200 Subject: [PATCH 1/4] New errors detected and returned: ErrorSendMessageSpamSuspected, ErrorSendMessageDailyLimitExceeded --- src/core/abstract/MCErrorMessage.cpp | 5 ++++- src/core/smtp/MCSMTPSession.cpp | 8 ++++++++ src/objc/abstract/MCOConstants.h | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/abstract/MCErrorMessage.cpp b/src/core/abstract/MCErrorMessage.cpp index bbe65eb12..db1495efe 100644 --- a/src/core/abstract/MCErrorMessage.cpp +++ b/src/core/abstract/MCErrorMessage.cpp @@ -46,11 +46,14 @@ static const char * localizedDescriptionTable[] = { "An application specific password is required", /** MCOErrorGmailApplicationSpecificPasswordRequired */ "An error when requesting date", /** MCOErrorServerDate */ "No valid server found", /** MCOErrorNoValidServerFound */ + NULL, /** MCOErrorCustomCommand */ + "Cannot send message due to possible spam detected by server", /** MCOErrorSendMessageSpamSuspected */ + "User is over the limit for messages allowed to be sent in a single day", /** MCOErrorSendMessageDailyLimitExceeded */ }; String * mailcore::errorMessageWithErrorCode(ErrorCode errorCode) { - if (errorCode < 0) { + if (errorCode < 0 || errorCode == ErrorCustomCommand) { return NULL; } if (errorCode >= sizeof(localizedDescriptionTable) / sizeof(localizedDescriptionTable[0])) { diff --git a/src/core/smtp/MCSMTPSession.cpp b/src/core/smtp/MCSMTPSession.cpp index 0c2016fd0..e6f4207bb 100644 --- a/src/core/smtp/MCSMTPSession.cpp +++ b/src/core/smtp/MCSMTPSession.cpp @@ -682,6 +682,14 @@ void SMTPSession::sendMessage(Address * from, Array * recipients, Data * message goto err; } } + else if (responseCode == 521 && response->locationOfString(MCSTR("limit")) != -1) { + * pError = ErrorSendMessageDailyLimitExceeded; + goto err; + } + else if (responseCode == 554 && response->locationOfString(MCSTR("spam")) != -1) { + * pError = ErrorSendMessageSpamSuspected; + goto err; + } * pError = ErrorSendMessage; MC_SAFE_REPLACE_COPY(String, mLastSMTPResponse, response); diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index 54648a0f3..ac87ba28d 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -413,6 +413,10 @@ typedef NS_ENUM(NSInteger, MCOErrorCode) { MCOErrorNoValidServerFound, /** Error while running custom command */ MCOErrorCustomCommand, + /** Spam was suspected by server */ + MCOErrorSendMessageSpamSuspected, + /** Daily limit of sent messages was hit */ + MCOErrorSendMessageDailyLimitExceeded, /** The count of all errors */ MCOErrorCodeCount, }; From a77fcf156a317f13c773281b34bad099238bc75e Mon Sep 17 00:00:00 2001 From: Sergei Epatov Date: Wed, 27 Jan 2016 11:31:04 +0200 Subject: [PATCH 2/4] =?UTF-8?q?Fix=20error=20handling=20add=20core?= =?UTF-8?q?=E2=80=93constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/abstract/MCMessageConstants.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/abstract/MCMessageConstants.h b/src/core/abstract/MCMessageConstants.h index 7d7403dac..a0522560a 100644 --- a/src/core/abstract/MCMessageConstants.h +++ b/src/core/abstract/MCMessageConstants.h @@ -253,6 +253,8 @@ namespace mailcore { ErrorServerDate, ErrorNoValidServerFound, ErrorCustomCommand, + ErrorSendMessageSpamSuspected, + ErrorSendMessageDailyLimitExceeded }; enum PartType { From d01b7c38666b48f55685d6bf0a6304d7a86e4b3f Mon Sep 17 00:00:00 2001 From: Sergei Epatov Date: Wed, 27 Jan 2016 12:04:23 +0200 Subject: [PATCH 3/4] Properly handle ErrorCustomCommand in MCErrorMessage --- src/core/abstract/MCErrorMessage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/abstract/MCErrorMessage.cpp b/src/core/abstract/MCErrorMessage.cpp index db1495efe..2f3d2c983 100644 --- a/src/core/abstract/MCErrorMessage.cpp +++ b/src/core/abstract/MCErrorMessage.cpp @@ -46,14 +46,14 @@ static const char * localizedDescriptionTable[] = { "An application specific password is required", /** MCOErrorGmailApplicationSpecificPasswordRequired */ "An error when requesting date", /** MCOErrorServerDate */ "No valid server found", /** MCOErrorNoValidServerFound */ - NULL, /** MCOErrorCustomCommand */ + "Error while running custom command", /** MCOErrorCustomCommand */ "Cannot send message due to possible spam detected by server", /** MCOErrorSendMessageSpamSuspected */ "User is over the limit for messages allowed to be sent in a single day", /** MCOErrorSendMessageDailyLimitExceeded */ }; String * mailcore::errorMessageWithErrorCode(ErrorCode errorCode) { - if (errorCode < 0 || errorCode == ErrorCustomCommand) { + if (errorCode < 0) { return NULL; } if (errorCode >= sizeof(localizedDescriptionTable) / sizeof(localizedDescriptionTable[0])) { From cd9a226a8e2f3ae69e78a5d4e48a55d92fb484fe Mon Sep 17 00:00:00 2001 From: Sergei Epatov Date: Mon, 1 Feb 2016 11:48:15 +0200 Subject: [PATCH 4/4] Change error prefix to RSMErrorYahoo, change error msg substring to 'over the limit' --- src/core/abstract/MCMessageConstants.h | 4 ++-- src/core/smtp/MCSMTPSession.cpp | 6 +++--- src/objc/abstract/MCOConstants.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/abstract/MCMessageConstants.h b/src/core/abstract/MCMessageConstants.h index a0522560a..d1029b138 100644 --- a/src/core/abstract/MCMessageConstants.h +++ b/src/core/abstract/MCMessageConstants.h @@ -253,8 +253,8 @@ namespace mailcore { ErrorServerDate, ErrorNoValidServerFound, ErrorCustomCommand, - ErrorSendMessageSpamSuspected, - ErrorSendMessageDailyLimitExceeded + ErrorYahooSendMessageSpamSuspected, + ErrorYahooSendMessageDailyLimitExceeded }; enum PartType { diff --git a/src/core/smtp/MCSMTPSession.cpp b/src/core/smtp/MCSMTPSession.cpp index e6f4207bb..2693737df 100644 --- a/src/core/smtp/MCSMTPSession.cpp +++ b/src/core/smtp/MCSMTPSession.cpp @@ -682,12 +682,12 @@ void SMTPSession::sendMessage(Address * from, Array * recipients, Data * message goto err; } } - else if (responseCode == 521 && response->locationOfString(MCSTR("limit")) != -1) { - * pError = ErrorSendMessageDailyLimitExceeded; + else if (responseCode == 521 && response->locationOfString(MCSTR("over the limit")) != -1) { + * pError = ErrorYahooSendMessageDailyLimitExceeded; goto err; } else if (responseCode == 554 && response->locationOfString(MCSTR("spam")) != -1) { - * pError = ErrorSendMessageSpamSuspected; + * pError = ErrorYahooSendMessageSpamSuspected; goto err; } diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index ac87ba28d..419d8485a 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -414,9 +414,9 @@ typedef NS_ENUM(NSInteger, MCOErrorCode) { /** Error while running custom command */ MCOErrorCustomCommand, /** Spam was suspected by server */ - MCOErrorSendMessageSpamSuspected, + MCOErrorYahooSendMessageSpamSuspected, /** Daily limit of sent messages was hit */ - MCOErrorSendMessageDailyLimitExceeded, + MCOErrorYahooSendMessageDailyLimitExceeded, /** The count of all errors */ MCOErrorCodeCount, };