0 votes

Thank you for the great product. However, when I tried to connect to imap.google.com via a proxy I got the exception:
"Proxy responded with a 302 code – Found."

How this should be handled? Here is my code:

ProxyFactory factory = new ProxyFactory();
string host = "64.27.0.30";
IProxyClient proxy = factory.CreateProxy(ProxyType.Http, host, 80);
try
{
    Socket socket = proxy.Connect("imap.gmail.com", Imap.DefaultPort);
    Imap client = new Imap();
    client.AttachSSL(socket, "imap.gmail.com");
    client.Close();
}
catch (Exception e)
{
    Console.WriteLine("{0}", e.Message);
}

Thank you!

by
edited by

1 Answer

0 votes

You need to connect to imap.gmail.com IMAP server over SSL:

Your code should look as follows (note Imap.DefaultSSLPort constant):

string host = "62.27.0.30";
IProxyClient proxy = factory.CreateProxy(ProxyType.Http, host, 80);
Socket socket = proxy.Connect("imap.gmail.com", Imap.DefaultSSLPort);

using(Imap imap = new Imap())
{
    imap.AttachSSL(socket, "imap.gmail.com");

    // ...

    imap.Close();
}
by (297k points)
...