Hi Tomas,Thank you for your reply.My HTTP proxy does not need any credentials; besides, after adding theseproxyClient.getState().setProxyCredentials(new AuthScope(proxy_host,proxy_port, null), new UsernamePasswordCredentials("", ""));
I still cannot get it to work.In http://code.google.com/p/gmail4j/source/browse/trunk/src/main/java/com/googlecode/gmail4j/http/HttpProxyAwareSslSocketFactory.java?r=32&spec=svn32, I notice in particular the following line in the
public Socket createSocket() throws IOException {
//FIXME doesn't work log.debug("Creating socket! with proxy: " + proxy.address());
ProxyClient proxyClient = new ProxyClient();
proxyClient.getHostConfiguration().setHost("nmap.gmail.com", 993);
proxyClient.getHostConfiguration().setProxy("**", 123);
proxyClient.getState().setCredentials(new AuthScope("172.16.1.99", 993),
new UsernamePasswordCredentials(TestConfigurer.getInstance().getGmailCredentials().getUsername(),
new String(TestConfigurer.getInstance().getGmailCredentials().getPasword())));
proxyClient.getState().setProxyCredentials(AuthScope.ANY
, new UsernamePasswordCredentials("tomasv", "***"));
ProxyClient.ConnectResponse resp = proxyClient.connect();
return resp.getSocket();
} Do you remember whether this proxy functionality ever worked? I would greatly appreciate if you could please point out to me how to achieve connecting to IMAP server through http proxy. If this is all that do the work, I am surprised.Thank you once again!Best regards,Bin.
On Mon, May 23, 2011 at 8:39 PM, Tomas Varaneckas <tomas.va...@gmail.com> wrote:
Hi Bin,I haven't looked at Gmail4j for quite a while, but hopefully this source code will be helpful, browse around. It's from a project where proxy settings work:Try setting proxy credentials:
conn.setProxyCredentials(user, pass.toCharArray()); Hopefully this helps. Good luck!TomasOn Tue, May 24, 2011 at 01:40, Bin Pan <bpan...@gmail.com> wrote:
Hi Tomas,I saw your development of gmail4j can handle gmail using IMAP through an HTTP proxy. But I could not get it to work. I tried to send you a message from your webpage; don't know whether you got it or not.Basically, I managed to get java code for ImapGmailClient to work without any proxy server. But when I use the same code behind a proxy server after adding
((ProxyAware) connection).setProxy(proxy_host, proxy_port);
I just cannot get connection to imap server.
On the other hand, using RssGmailClient, I can get it to work after adding
connection.setProxy(proxy_host, proxy_port);
Here, the proxy_host and proxy_port in both places are the same.In the documentation of gmail4j http://www.varaneckas.com/gmail4j/0.3/apidocs/com/googlecode/gmail4j/javamail/ImapGmailConnection.html , it clearly says:
ImapGmailConnection is ProxyAware, allowing to use JavaMail IMAP via HTTP proxy, which was not possible by JavaMail design.Could you please suggest where I did wrong? Thanks a lot.Best regards,Bin.