eba
eba

Reputation: 979

.net pop3 over http proxy

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?

Upvotes: 0

Views: 1895

Answers (2)

Pawel Lesnikowski
Pawel Lesnikowski

Reputation: 6381

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/

Upvotes: 1

foens
foens

Reputation: 8672

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.

Upvotes: 1

Related Questions