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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user