librelist archives

« back to archive

Error with IMAP connection, connectToServer:port:connectionType:authType:login: returns with error after 10 minutes

Error with IMAP connection, connectToServer:port:connectionType:authType:login: returns with error after 10 minutes

From:
Jose Villar
Date:
2012-08-02 @ 01:44
 I'm having trouble setting up MailCore. I followed the instructions at
http://libmailcore.com/#iosadding and wrote a simple method to test IMAP.
It unfortunately resulted in the error "IMAP connection lost". The
method connectToServer:port:connectionType:authType:login: takes around 10
minutes to return this error. I tried with different email accounts with no
success. I also tried using an incorrect password to see if the method
returned sooner or the error was different, but the same "IMAP connection
lost" error happened after around 10 minutes. I tried both with the
simulator and on a device and had the same results.

I'm using the port and server indicated here
http://support.google.com/mail/bin/answer.py?hl=en&answer=78799 and just to
make sure the error was not in one of the parameters passed to
connectToServer:port:connectionType:authType:login: I wrote a python script
passing the same parameters, and it allowed me to successfully connect to
the Gmail IMAP server.

I'm using Xcode 4.4 and iOS SDK 5.1

*2012-08-02 02:37:38.473 <appname>[294:707] Testing IMAP connection...*

*2012-08-02 02:47:40.503 <appname>[294:707] Error:Error Domain=mailcore
Code=8 "IMAP connection lost" UserInfo=0x379e50
{NSLocalizedDescription=IMAP connection lost}*


- (IBAction)startImap:(id)sender

{

    NSLog(@"Testing IMAP connection...");

    CTCoreAccount *account = [[CTCoreAccount alloc] init];

    BOOL success = [account connectToServer:@"imap.gmail.com" port:993
connectionType:CTConnectionTypePlain authType:CTImapAuthTypePlain login:
@"<fullemail>" password:@"<password>"];

    if (!success) {

        // Display the error contained in account.lastError

        NSLog(@"Error:%@", account.lastError);

    } else {

        NSSet *subFolders = [account subscribedFolders];

        NSLog(@"Folders:");

        for(NSString *folder in subFolders) {

            NSLog(@"%@", folder);

        }

    }

}

I'm I doing something wrong?

Thanks

Re: [mailcore] Error with IMAP connection, connectToServer:port:connectionType:authType:login: returns with error after 10 minutes

From:
Matt Ronge
Date:
2012-08-02 @ 02:02
Hi Jose,

On Aug 1, 2012, at 8:44 PM, Jose Villar <ralliveso@gmail.com> wrote:

<snip>

> 
>     BOOL success = [account connectToServer:@"imap.gmail.com" port:993 
connectionType:CTConnectionTypePlain authType:CTImapAuthTypePlain 
login:@"<fullemail>" password:@"<password>"];

Try CTConnectionTypeTLS instead of CTConnectionTypePlain, that should do 
the trick.


--
Matt Ronge
mronge@mronge.com
iOS Developer & Consultant
Central Atomics Inc.

Re: [mailcore] Error with IMAP connection, connectToServer:port:connectionType:authType:login: returns with error after 10 minutes

From:
Jose Villar
Date:
2012-08-02 @ 02:34
That was it. Thanks a lot.

On Thu, Aug 2, 2012 at 4:02 AM, Matt Ronge <mronge@mronge.com> wrote:

>
> Hi Jose,
>
> On Aug 1, 2012, at 8:44 PM, Jose Villar <ralliveso@gmail.com> wrote:
>
> <snip>
>
> >
> >     BOOL success = [account connectToServer:@"imap.gmail.com" port:993
> connectionType:CTConnectionTypePlain authType:CTImapAuthTypePlain 
login:@"<fullemail>"
> password:@"<password>"];
>
> Try CTConnectionTypeTLS instead of CTConnectionTypePlain, that should do
> the trick.
>
>
> --
> Matt Ronge
> mronge@mronge.com
> iOS Developer & Consultant
> Central Atomics Inc.
>