Search code examples
iosmailcore

Trouble connecting to a google apps server via MailCore


I'm trying to connect to Google Apps email server via IMAP. The code I am using below, every time I try to connect I get the error: Parse error Anyone know the source of this error?

    int port = 993;
    CTCoreAccount *account = [[CTCoreAccount alloc] init];
    BOOL success = [account  connectToServer:@"imap.gmail.com"
                                        port:port
                              connectionType:CTConnectionTypeStartTLS
                                    authType:CTImapAuthTypePlain
                                       login:login
                                    password:password];
    NSLog(@"Port: %d",port);
    if (!success) {
        NSLog(@"Connection failed, error: %@",[account.lastError localizedDescription]);
    }
    else {
        NSLog(@"Connection succeeded");
    }

Solution

  • There were two issues simultaneously going on here. The first was that my network had a firewall and that was the source of the Parse Error.

    Second, when you need to connect to Google Maps IMAP server, you'll need to use the CTConnectionTypeTLS instead of CTConnectionTypeStartTLS, because the second one makes the server go bonkers.