嘿guyz帮助我解决了在尝试使用MailCore从gmail帐户(我自己的gmail获得适当的凭据)获取电子邮件时遇到的问题我得到了以下错误。
Error downloading message headers:Error Domain=MCOErrorDomain Code=1 "A stable connection to the server could not be established." UserInfo=0x8191180 {NSLocalizedDescription=A stable connection to the server could not be established.}
2015-04-20 14:21:25.534 MailCoreForMobile[873:11303] The post man delivereth:(null)
鉴于以下是我试图编译的Code-Stub。
+ (void)fetchAllMails{
MCOIMAPSession *session = [[MCOIMAPSession alloc] init];
[session setHostname:@"imap.gmail.com"];
[session setPort:993];
[session setUsername:@"**********@gmail.com"];
[session setPassword:@"************"];
[session setConnectionType:MCOConnectionTypeTLS];
[session setAuthType:MCOAuthTypeSASLPlain];
MCOIMAPMessagesRequestKind requestKind = MCOIMAPMessagesRequestKindHeaderSubject;
NSString *folder = @"INBOX";
MCOIndexSet *uids = [MCOIndexSet indexSetWithRange:MCORangeMake(1, UINT64_MAX)];
MCOIMAPFetchMessagesOperation *fetchOperation = [session fetchMessagesByUIDOperationWithFolder:folder requestKind:requestKind uids:uids];
[fetchOperation start:^(NSError * error, NSArray * fetchedMessages, MCOIndexSet * vanishedMessages) {
if(error) {
NSLog(@"Error downloading message headers:%@", error);
}
NSLog(@"The post man delivereth:%@", fetchedMessages);
}];
}
但是,如果我尝试使用雅虎帐户来获取邮件它工作正常.. 现在我很困惑,如果问题出在我的Gmail帐户上,或者我使用了错误的端口..
任何帮助都将非常感谢。