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

This commit is contained in:
Matt Ronge
2012-09-10 16:46:28 -05:00
parent f9581ee615
commit fef9c331f3
2 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -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;
}
+13 -3
View File
@@ -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);
}