ImapClient Failing to connect without any exceptions or errors.

Topics: Issues
Nov 21, 2014 at 9:16 AM
Hello All,

I am trying to port an Windows application on Mac using Xamarin framework which helps to port C# applications.
Using ImapX library I am trying to fetch mails but my ImapClient does not get connected and returns false value. It tries to connect, there is some processing for few seconds and then the Connect() function returns 'false', without throwing any exceptions or errors!

What can be the cause of this? Following is my code
   var client = new ImapX.ImapClient("imap.gmail.com", true);
   bool cc=client.Connect();
Any help will be highly appreciated. Thanks a ton in advance!
-Prerana
Coordinator
Nov 23, 2014 at 10:51 AM
Hi Prerana,

are you using the Mono based library or the usual .Net? The behavior is strange and I have no way to check it myself as don't have a Mac. Can you try to do the following:
  • Compile ImapX using Mono (if you don't know how, just let me know I will compile it and upload a binary for you).
  • Try to create a log file a described in the documentation and post it here.
Greets,

Pavel
Nov 24, 2014 at 4:03 AM
Hi Pavel,
Thanks a ton for the reply. I was using the usual .Net library in Mono. I followed your instructions :-
  • Downloaded the source code and compiled it using Xamarin Studio. Used the newly created binary file in my project.
  • Created the log file same as mentioned in the docs but no logs were generated in it, its blank. Following is how I am logging it :-
Debug.Listeners.Add(new TextWriterTraceListener(Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "test.txt")));
Debug.AutoFlush = true;
var client = new ImapX.ImapClient ("imap.gmail.com", true);
bool cc=client.Connect ();
// After you created the client, set
 client.IsDebug = true;
Is it correct ?
Coordinator
Nov 24, 2014 at 11:54 AM
Hi Prerana,

make sure that you compile your project with the DEBUG constant definition enabled and set client.IsDebug = true before you make a call to the Connect method.

Greets,

Pavel
Nov 25, 2014 at 11:27 AM
Hi Pavel,

I made changes as you said, no logs yet :( Meanwhile I fixed the issue for time being by disabling certificate validation mentioned in the following discussion :-

https://imapx.codeplex.com/discussions/530206

But it would be great if I can get it working with certificate validation enabled. Thanks a ton for your time and response :)

-Prerana
Coordinator
Nov 29, 2014 at 11:07 AM
Hi Prerana,

Following the link provided in the thread you mentioned, you can try to run the following commands:
mozroots --import --sync
certmgr -ssl imaps://imap.gmail.com:993
This will import the main root certificates and add the intermediate certificate for GMail.

Greets,

Pavel
Dec 1, 2014 at 3:54 AM
Hi Pavel,
I tried the command you mentioned, before importing the certificate an warning is presented
 *** WARNING: Certificate signature is INVALID ***
So should I go ahead importing them? For adding certificate for Hotmail, the commands will be as followed right?
certmgr -ssl imaps://imap-mail.outlook.com:993  
Thanks a ton in advance.

-Prerana
Coordinator
Dec 1, 2014 at 4:58 PM
Hi Prerana,

I get the same warning on Ubuntu, simply import the certificate ignoring it.

Greets,

Pavel
Dec 2, 2014 at 11:05 AM
Hi Pavel,

Thanks a ton it worked!! Thank you for your time. Have a great day ahead. Happy coding :)

-Prerana