.net pop3 over http proxy

霸气de小男生 提交于 2019-12-25 06:25:22

问题


so, i got mailsystem.net from codeplex(http://mailsystem.codeplex.com/), to write pop3 client. problem is, i want to use http proxy. found some hints at:

How to open socket thru proxy server in .Net C#?

and here is my code:

Pop3Client pop = new Pop3Client();
Socket sock = new Socket(AddressFamily.InterNetwork,
                             SocketType.Stream,
                             ProtocolType.Tcp);
sock.Connect("79.172.35.74", 82); // here is proxy
sock.Send(Encoding.UTF8.GetBytes("CONNECT pop.yandex.ru:110 HTTP/1.1<CR><LF>")); // here pop3 server
sock.Send(Encoding.UTF8.GetBytes("<CR><LF>"));
byte[] buffer = new byte[25];
sock.Receive(buffer);
pop.Client = sock;
pop.Connect(config.pop3.host, config.pop3.username, config.pop3.password);

so, it fails at last line, with socket exception. what can i do? or any free pop3client libraries with proxy support?


回答1:


Quote from the post you link to:

  1. Connect to proxy.
  2. Issue CONNECT Host:Port HTTP/1.1<CR><LF>
  3. Issue <CR><LF>
  4. Wait for a line of response. If it contains HTTP/1.X 200, the connection is successful.
  5. Read further lines of response until you receive an empty line.
  6. Now, you are connected to the outside world through a proxy. Do any data exchange you want.

Where is it that you do bullet nr. 5? Where do you read all lines until you receive an empty line?

Other then that, I do not know what the problem might be. You could choose to use Starksoft Proxy library to help you.




回答2:


This line:

pop.Connect(config.pop3.host, config.pop3.username, config.pop3.password);

is not needed, your socket is already connected. You should only log in.

You may try Mail.dll POP3 component. Please note that it's a commercial (not free) product that I've created.

It supports HTTP and SOCKS proxies:

http://www.lesnikowski.com/blog/index.php/imap-pop3-smtp-via-http-socks-proxy/



来源:https://stackoverflow.com/questions/5248269/net-pop3-over-http-proxy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!