From fef9c331f39cc13f4aae9fddbf8a1075f5d801db Mon Sep 17 00:00:00 2001 From: Matt Ronge Date: Mon, 10 Sep 2012 16:46:28 -0500 Subject: [PATCH] Fixed an SMTP bug where an error wasn't returned when the username/login was wrong. Also added a nicer error message for when this happens --- Source/CTSMTPConnection.m | 4 ++-- Source/MailCoreUtilities.m | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/CTSMTPConnection.m b/Source/CTSMTPConnection.m index e107fae..9bc7fe9 100644 --- a/Source/CTSMTPConnection.m +++ b/Source/CTSMTPConnection.m @@ -67,7 +67,7 @@ } } if (auth) { - [smtpObj authenticateWithUsername:username password:password server:server]; + success = [smtpObj authenticateWithUsername:username password:password server:server]; if (!success) { goto error; } @@ -129,7 +129,7 @@ error: } } if (auth) { - [smtpObj authenticateWithUsername:username password:password server:server]; + success = [smtpObj authenticateWithUsername:username password:password server:server]; if (!success) { goto error; } diff --git a/Source/MailCoreUtilities.m b/Source/MailCoreUtilities.m index c674413..626967a 100644 --- a/Source/MailCoreUtilities.m +++ b/Source/MailCoreUtilities.m @@ -67,10 +67,20 @@ NSError* MailCoreCreateError(int errcode, NSString *description) { } NSError* MailCoreCreateErrorFromSMTPCode(int errcode) { - const char *errStr = mailsmtp_strerror(errcode); NSString *description = @"Unknown error"; - if (errStr) { - description = [[NSString alloc] initWithCString:errStr encoding:NSUTF8StringEncoding]; + + switch (errcode) { + case MAILSMTP_ERROR_AUTH_LOGIN: + description = @"Invalid username or password"; + break; + + default: { + const char *errStr = mailsmtp_strerror(errcode); + if (errStr) { + description = [[NSString alloc] initWithCString:errStr encoding:NSUTF8StringEncoding]; + } + break; + } } return MailCoreCreateError(errcode, description); }