mailcore2 imap 错误域=MCOErrorDomain 代码=5
Posted
技术标签:
【中文标题】mailcore2 imap 错误域=MCOErrorDomain 代码=5【英文标题】:mailcore2 imap Error Domain=MCOErrorDomain Code=5 【发布时间】:2015-04-15 20:59:05 【问题描述】:我又来制作mailcore2的相关问题,根据以往的错误,和大家分享,还是没找到下面这个问题的解决方法,所以我遇到的问题再分发,也希望能得到更多的帮助,谢谢!
Mailcore2 using the code below:
self.imapSession = [[MCOIMAPSession alloc] init];
self.imapSession.hostname = hostname;
self.imapSession.port = 993;
self.imapSession.username = username;
self.imapSession.password = password;
if (oauth2Token != nil)
self.imapSession.OAuth2Token = oauth2Token;
self.imapSession.authType = MCOAuthTypeXOAuth2;
self.imapSession.connectionType = MCOConnectionTypeTLS;
MasterViewController * __weak weakSelf = self;
self.imapSession.connectionLogger = ^(void * connectionID, MCOConnectionLogType type, NSData * data)
@synchronized(weakSelf)
if (type != MCOConnectionLogTypeSentPrivate)
NSLog(@"event logged:%p %i withData: %@", connectionID, type, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
;
// Reset the inbox
self.messages = nil;
self.totalNumberOfInboxMessages = -1;
self.isLoading = NO;
self.messagePreviews = [NSMutableDictionary dictionary];
[self.tableView reloadData];
NSLog(@"checking account");
self.imapCheckOp = [self.imapSession checkAccountOperation];
[self.imapCheckOp start:^(NSError *error)
MasterViewController *strongSelf = weakSelf;
NSLog(@"finished checking account.");
if (error == nil)
[strongSelf loadLastNMessages:NUMBER_OF_MESSAGES_TO_LOAD];
else
NSLog(@"error loading account: %@", error);
strongSelf.imapCheckOp = nil;
];
当我使用ios8.1设备时,报错信息如下,控制台输出:
checking account
2015-02-15 10:58:36.712 MailCoreTest[11971:2988194] event logged:0x166a4d50 0 withData: * OK [CAPABILITY IMAP4 IMAP4rev1 IDLE XAPPLEPUSHSERVICE ID UIDPLUS AUTH=LOGIN NAMESPACE] QQMail IMAP4Server ready
2015-02-15 10:58:36.821 MailCoreTest[11971:2988194] event logged:0x166a4d50 0 withData: (null)
2015-02-15 10:58:36.824 MailCoreTest[11971:2988128] finished checking account.
2015-02-15 10:58:36.825 MailCoreTest[11971:2988128] error loading account: Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials." UserInfo=0x16596ec0 NSLocalizedDescription=Unable to authenticate with the current session's credentials.
But when I use iOS8.0 devices, console to print the results are as follows:
checking account
2015-02-15 11:22:53.249 MailCoreTest[7853:1742121] finished checking account.
2015-02-15 11:22:53.249 MailCoreTest[7853:1742121] error loading account: Error Domain=MCOErrorDomain Code=1 "A stable connection to the server could not be established." UserInfo=0x17e50ab0 NSLocalizedDescription=A stable connection to the server could not be established.
请帮帮我,我接触Objective-C的时间很短,但我必须尽我所能积极进取,仍然希望给出详细的解决方案,再次真诚感谢你,辛苦了!
【问题讨论】:
好像认证信息有误。 【参考方案1】:是的,这是一个身份验证问题,我的应用程序也遇到了同样的问题,但之前它运行良好。 收到此错误后,我检查了我的 gmail 帐户,并且有一封来自 Google 的电子邮件,主题为“阻止可疑登录”,并且此登录是美国加利福尼亚州的。实际上,我的申请正在审核中,因此被拒绝。
然后我发现gmail正在禁用未经授权的IP。
您必须为 gmail 帐户启用两步验证才能解决此问题并生成应用专用密码。在您的应用中使用该密码,它会正常工作。
按照下面的谷歌链接生成应用程序专用密码。
https://support.google.com/mail/answer/1173270?hl=en
【讨论】:
以上是关于mailcore2 imap 错误域=MCOErrorDomain 代码=5的主要内容,如果未能解决你的问题,请参考以下文章